Ejemplo n.º 1
0
    def on_text_message(self, message_entity):
        # Detect command and the predicate of the message
        command = ""
        predicate = ""
        print("----------------------------------------------")
        try:
            command = helper.predicate(message_entity).split(' ', 1)[0]
            predicate = helper.predicate(message_entity).split(' ', 1)[1]
        except IndexError:
            print "Comando sin segundo parametro"
        # Log
        # helper.log_mac(message_entity)
        who = helper.get_who_send(message_entity)
        conversation = message_entity.getFrom()

        if helper.is_command(message_entity):
            main.handle_message(self, command, predicate, message_entity, who, conversation)
Ejemplo n.º 2
0
def is_in_command_list(message_entity):
    try:
        command = helper.predicate(message_entity).split(' ', 1)[0]
        if command in commands:
            return True
    except:
        return False
        
    return False
Ejemplo n.º 3
0
    def on_text_message(self, message_entity):
        # Detect command and the predicate of the message
        command = ""
        predicate = ""

        try:
            command = helper.predicate(message_entity).split(' ', 1)[0]
            predicate = helper.predicate(message_entity).split(' ', 1)[1]
        except IndexError:
            print("No predicate")

        # Log
        # helper.log_mac(message_entity)

        who = message_entity.getFrom()
        if message_entity.isGroupMessage():
            who = message_entity.getParticipant()

        if helper.is_command(message_entity):
            handle_message(self, command, predicate, message_entity, who,
                           message_entity.getFrom())
Ejemplo n.º 4
0
    def __init__(self, message_entity):
        self.message = helper.clean_message(message_entity)
        self.who = helper.get_who_send(message_entity)
        self.who_name = helper.sender_name(message_entity)
        self.conversation = message_entity.getFrom()
        self.message_entity = message_entity

        # These two attributes are just easier ways to identify instructions
        # But they are not really needed since you have the whole message
        # But I use these a lot so f**k it, lemme be happy
        # ===================================================================
        # command is what goes after '!'
        self.command = helper.command(message_entity)
        # predicate is what goes after the command
        self.predicate = helper.predicate(message_entity)
Ejemplo n.º 5
0
 def put_command(self):
     self.command = helper.command(self.message_entity)
     self.predicate = helper.predicate(self.message_entity)