Esempio n. 1
0
    def __init__(self, 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
        self.valid = False
        self.message = ""
        self.text = ""
        self.file_path = None
        self.command = None
        self.predicate = None

        self.build()
Esempio n. 2
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)
Esempio n. 3
0
def handle_message(instance, command, predicate, message_entity, who,
                   conversation):
    # N***a who send the message
    who_name = helper.sender_name(message_entity)

    if command == "hi" or command == "hola":
        answer = "Hola *" + who_name + "*"
        mac.send_message(instance, answer, conversation)

    elif command == "help":
        answer = "Hola *" + who_name + "*\nNo puedo ayudarte por ahora"
        mac.send_message(instance, answer, conversation)

    elif command == "siono":
        yesno = YesNo(instance, conversation)
        yesno.send_yesno()

    elif command == "yt":
        WAYoutube(instance, who, conversation)

    elif command == "✔":
        response = match.confirm_match()
        mac.send_message(instance, response, conversation)

    elif command == "elo":
        args = [x.strip() for x in predicate.split(',')]
        if args[0] == "query":
            query = predicate.split(', ', 1)[-1]
            results = elo.query(query)
            mac.send_message(instance, results, conversation)
        else:
            ranks = elo.ranks(predicate)
            mac.send_message(instance, ranks, conversation)

    elif command == "match":
        args = [x.strip() for x in predicate.split(',')]
        if len(args) <= 0:
            mac.send_message(instance, "missing game and results",
                             conversation)
        elif len(args) == 1:
            mac.send_message(instance, "missgin results", conversation)
        elif len(args) >= 2:
            if elo.is_valid_smash(args[0]) and (who == helper.me):
                confirmation = match.record_match(args[0], args[1])
                mac.send_message(instance, confirmation, conversation)
            elif elo.is_valid_smash(args[0]) and (who != helper.me):
                response = "@" + who_name + ", not alllowed"
                mac.send_message(instance, response, conversation)
            else:
                confirmation = match.record_match(args[0], args[1])
                mac.send_message(instance, confirmation, conversation)

    elif command == "poll2":
        poll2 = PollKing(instance, conversation, who, predicate)
        poll2.send_poll()

    elif command == "poll":
        # args = <title>, <identifier (optional)>
        args = [x.strip() for x in predicate.split(',')]
        if len(args) <= 0:
            mac.send_message(instance, "_Argumentos invalidos_", conversation)
            return
        if len(args) >= 1:
            if args[0] == "finish":
                poll.finish_my_poll(instance, who, conversation)
                return
            if len(args) == 1:
                title = args[0]
                basic_boll = poll.WAPoll(instance, conversation, who, title)
                basic_boll.send_poll()
            elif len(args) >= 2:
                title = args[0]
                identifier = args[1]
                basic_boll = poll.WAPoll(instance, conversation, who, title,
                                         identifier)
                basic_boll.send_poll()

    elif command == "trip":
        mac.send_message(instance, trip.print_debts(), conversation)

    else:
        # No command for this so use IA
        #answer = cleverbot_answer(command + " " + predicate)
        answer = wolfram_answer(command + " " + predicate, who_name)
        if answer == "*?*":
            return
        else:
            mac.send_message(instance, answer, conversation)
Esempio n. 4
0
def handle_message(instance, command, predicate, message_entity, who,
                   conversation):
    if command == "hola":
        who_name = helper.sender_name(message_entity)
        bot.send_message(instance, "Hola *" + who_name + "*".decode('utf8'),
                         conversation)

    elif command == "ayuda":

        answer = """*Lista de comandos*\n
                 !hola\n
                 !noticia <videojuegos,ciencia,series,música,actualidad>\n
                 !chollo\n
                 !anime <temp, temp lista, búsqueda>\n
                 !adv\n
                 !chiste\n
                 !siono \n
                 !ayuda"""

        bot.send_message(instance, answer, conversation)

    elif command == "siono":
        yesno = YesNo(instance, conversation)
        yesno.send_yesno()

    elif command == "anime":
        anime = None
        person = helper.get_who_send(message_entity)
        if predicate:
            if predicate == "temp":
                anime = Anime(instance, conversation, person, param='season')
            elif predicate == "temp lista":
                anime = Anime(instance,
                              conversation,
                              person,
                              param='season_list')
            elif predicate.isdigit():
                anime = Anime(instance,
                              conversation,
                              person,
                              param='anime_num',
                              num=predicate)
            else:
                commands = predicate.split()
                if len(commands) == 2 and commands[0] == "temp" and commands[
                        1].isdigit():
                    anime = Anime(instance,
                                  conversation,
                                  person,
                                  param='season_num',
                                  num=commands[1])
                # Buscar anime
                else:
                    anime = Anime(instance,
                                  conversation,
                                  person,
                                  param=predicate)
        else:
            #Anime aleatorio
            anime = Anime(instance, conversation, person)

        if (anime):
            anime.send_anime()

    elif command == "chollo":
        chollo = Chollo(instance, conversation)
        chollo.build()
        chollo.send_chollo()

    # elif command == "frase":
    #     quote = Quote(instance, conversation)
    #     quote.send_quote()

    elif command == "chiste":
        chiste = Chiste(instance, conversation)
        chiste.send_chiste()

    # elif command == "wur":
    #     wur = WUR(instance, conversation)
    #     wur.build()
    #     wur.send_wur()

    elif command == "adv":
        adv = ADV(instance, conversation)
        adv.send_adv()

    elif command == "noticia":
        l = ['videojuegos', 'ciencia', 'series', 'música', 'actualidad']
        if predicate.encode('utf8') in l:
            noticia = Noticias(instance, conversation, predicate)
            noticia.send_noticia()

    #cambia la foto del perfil
    elif command == "fotoPerfil":
        path = get_avatar()
        bot.profile_set_picture(instance, path)

    #cambia el estado del perfil
    elif command == "estado":
        if predicate:
            bot.profile_setStatus(instance, predicate)

    else:
        #return
        answer = cleverbot_answer(command + " " + predicate)
        bot.send_message(instance, answer, conversation)
Esempio n. 5
0
 def __init__(self, message_entity):
     self.who = helper.get_who_send(message_entity)
     self.conversation = message_entity.getFrom()
     self.who_name = helper.sender_name(message_entity)