diff --git a/bot.py b/bot.py index 24051d4271ec71674c761d258e8966837ed6fc5c..1ebd8667c12208ea0e976d21eab61f2bc744ff8b 100755 --- a/bot.py +++ b/bot.py @@ -6,9 +6,12 @@ from getpass import getpass from fbchat.models import * import useless import usefull +import random class Bot(Client): + ahah_liste = ['ahah', 'mdr', 'lol', 'Mort de rire !', 'Trop marrant', 'tu m\'as tué', 'xD', 'PTDR'] + def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs): self.markAsDelivered(thread_id, message_object.uid) self.markAsRead(thread_id) @@ -16,8 +19,8 @@ class Bot(Client): log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name)) to_send = Bot.tests(message_object.text, self.fetchThreadInfo(thread_id)[thread_id].name) - if (author_id != self.uid or 'A.N.U.B.I.S. :' not in message_object.text) and to_send is not None: - self.send(Message('A.N.U.B.I.S. :' + to_send), thread_id=thread_id, thread_type=thread_type) + if (author_id != self.uid or 'BOT :' not in message_object.text) and to_send is not None: + self.send(Message('BOT :' + to_send), thread_id=thread_id, thread_type=thread_type) @classmethod def tests(self, texte, channel=''): @@ -35,6 +38,7 @@ class Bot(Client): !kohlanta <nom>\n \ !rateau \n \ !maps <nom_du_lieu> <destination(facultatif)>, not yet fully fonctionnal\n \ + !ping \n\ !about -> vas-y test-moi !\n' return help_text if texte == '!useless': @@ -52,6 +56,10 @@ class Bot(Client): return useless.kohlanta(texte, channel) if texte == '!pipo': return useless.pipo() + if texte == '!ping': + return 'Pong !' + if any(word.lower() in texte.lower() for word in Bot.ahah_liste): + return random.choice(Bot.ahah_liste) if texte == '!rateau': return useless.getRateau() if '!meteo' in texte: diff --git a/requirements.txt b/requirements.txt index 625bdc8fb826ac8617b36d8f5626776e3dcda808..7a3fb236f05b38f8d1dacdf722176951ea463fe2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ requests fbchat -wikipedia \ No newline at end of file +wikipedia +googletrans \ No newline at end of file