-
Notifications
You must be signed in to change notification settings - Fork 360
Home
Daniel Cardenas edited this page Nov 20, 2016
·
7 revisions
This method will fire every time a message starting with ! is received.
Take a look at layer.py
(line 121).
'''
This method gets all you need in a command message.
For ex.
In group "ITS", daniel sent "!hola a todos"
@self = the instance (You need this to send reply with mac -> mac.send_message(instance,...))
@command = What comes after '!'. In this case "hola"
@predicate = What comes after command. In this case "a todos"
@who = The jID of the person who sent this. In this case daniel (check below for retrieving the name)
@conversation = The jId of the conversation. In this case the group "ITS".
NOTE: You can only send messages to conversations
'''
def handle_message(self, command, predicate, message_entity, who, conversation):
From here you add your own commands.
For example:
# Nigga who send the message (first name)
who_name = message_entity.getNotify().split(" ")[0]
if command == "hi"
answer = "Hi *" + who_name + "*"
mac.send_message(self, answer, conversation)
Right now Mac can send:
- Text
- Images
- Videos
-
instance
: instance fromhandle_message()
-
answer
: String to reply (Allows whatsapp format) -
conversation
: Conversation (usually the one fromhandle_message()
)
from app.mac import mac
...
mac.send_message(instance, answer, conversation)
-
instance
: instance fromhandle_message()
-
conversation
: Conversation (usually the one fromhandle_message()
) -
image_path
: Path to the image file -
caption
(optional): Text messsage
from app.mac import mac
...
mac.send_image(instance, conversation, image_path, caption)
-
instance
: instance fromhandle_message()
-
conversation
: Conversation (usually the one fromhandle_message()
) -
image_path
: Path to the video file -
caption
(optional): Text messsage
from app.mac import mac
...
mac.send_video(instance, conversation, video_path, caption)