Skip to content
Extraits de code Groupes Projets
Valider a49b1f4b rédigé par Loïc Wikle DUBARD's avatar Loïc Wikle DUBARD
Parcourir les fichiers

le bot serépondait lui même voilà d'où venait le spam...

parent 7b0cbdc7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
auth_file.py
sample*
sample_in.jpg
sample_out.jpg
insta_random.jpg
shitpostbot5k_latest.jpg
*__pycache__/*
__pycache__/*
......@@ -15,7 +15,7 @@ translator = Translator()
class Bot(Client):
ahah_liste = ['ahah', 'mdr', 'lol', 'Mort de rire !', 'Trop marrant', 'tu m\'as tué', 'xD', 'PTDR']
ahah_liste = ['ahah', 'mdr', 'lol', 'Mort de rire !', 'Trop marrant', 'xD', 'PTDR']
what_liste = ['wat', 'What', 'Nani', 'keske', 'dafuk', 'da fuk']
quizzes = {}
shitpostbot = {}
......@@ -27,16 +27,14 @@ class Bot(Client):
log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name))
# pour éviter le spam... et oui j'ai fait cette erreur là.....
if author_id != self.uid:
to_send = self.tests(message_object.text, thread_id=thread_id, thread_type=thread_type, author_id=author_id, channel=self.fetchThreadInfo(thread_id)[thread_id].name)
if (author_id != self.uid or 'BOT :' not in message_object.text) and to_send is not None:
if len(to_send) > 30:
self.send(Message("\n".join(to_send.split('\n')[: len(to_send) // 2])), thread_id=thread_id, thread_type=thread_type)
sleep(2)
self.send(Message("\n".join(to_send.split('\n')[len(to_send) // 2:])), thread_id=thread_id, thread_type=thread_type)
else:
if to_send is not None:
self.send(Message(to_send), thread_id=thread_id, thread_type=thread_type)
sleep(2)
elif author_id != self.author_id:
self.trigger_double_mots(message_object.text, thread_id, thread_type)
# self.shitpostbot5000()
......@@ -47,6 +45,7 @@ class Bot(Client):
print('Shitpostbot5000 a dégoté une nouvelle image...')
self.sendLocalImage(Bot.shitpostbot[chan][0].get_out(), thread_id=chan, thread_type=Bot.shitpostbot[chan][1])
# TODO: move test in a standard module to use it with different bots
def tests(self, texte, thread_id, thread_type, author_id, channel=''):
if texte == '!help':
......@@ -70,10 +69,11 @@ class Bot(Client):
'!memes <image_name_or_url> ; <texte1> ; <texte2(facultatif)>\n' + \
'!ping \n' + \
'!translate <phrase> ; <lang_source> ; <lang_dest>\n' + \
'!shitpostbot5000 [status|on|off|random <keyword(facultatif)>|timer] ... ne pas utiliser PLEASE\n' + \
'!shitpostbot5000 [status|on|off|random <keyword(facultatif)>] ... ne pas utiliser PLEASE\n' + \
'!title <newtitle>\n'\
'!listuser <newtitle>\n'\
'!about -> vas-y test-moi !\n'
return help_text
return 'Hummmm non j\'ai la flemme là'
elif '!translate' in texte:
texte = texte.replace('!translate ', '').split(' ; ')
try:
......@@ -95,7 +95,9 @@ class Bot(Client):
elif '!title ' in texte:
texte = texte.replace("!title ", '')
client.changeThreadTitle(texte, thread_id=thread_id, thread_type=thread_type)
# renomer qqn
# FIXME: make rename command work
elif '!rename' in texte:
texte = texte.replace('!rename ', '').split(' ; ')
for user in self.fetchAllUsersFromThreads([self.fetchThreadInfo(thread_id)[thread_id]]):
......@@ -103,7 +105,9 @@ class Bot(Client):
self.changeNickname(nickname=texte[1], user_id=user.uid, thread_id=thread_id, thread_type=thread_type)
else:
return random.choice(['T\'es sur de ton coup là ?', 'chais pas qui c\'est...'])
# kick qqn d'un group
# TODO: test remove
# kick qqn d'un groupe
elif '!remove ' in texte and thread_type == ThreadType.GROUP:
texte = texte.replace('!remove ', '').split(' ; ')
user_to_remove = None
......@@ -127,6 +131,7 @@ class Bot(Client):
return "la liste des gens dans le groupe :\n\n" "".join([user.name for user in self.fetchAllUsersFromThreads([self.fetchThreadInfo(thread_id)[thread_id]])])
# réinviter le dernier mec kické du group
# TODO: test reinvite
elif texte == '!reinvite':
if 'thread_id' in Bot.kicked:
self.addUsersToGroup(Bot.kicked[thread_id][-1].uid, thread_id=thread_id)
......@@ -151,6 +156,7 @@ class Bot(Client):
return 'T\'es débile ou quoi ? Je peux pas réinviter des gens que je n\'ai pas kické moi même en fait... \n\n\n Hummmm par contre je pourais éventuellement inviter des random mec...ou meuf...'
# SHitpostbot5000
# TODO: shitpostbot5000 random auto with timer
elif texte == '!shitpostbot5000 on':
if thread_id not in Bot.shitpostbot:
Bot.shitpostbot[thread_id] = [useless.Shitpostbot5000(), thread_type]
......@@ -171,8 +177,10 @@ class Bot(Client):
self.sendLocalImage(useless.Shitpostbot5000.random(texte), thread_id=thread_id, thread_type=thread_type)
# générateur de memes
elif any(words in texte for words in ['!memes templates', '!memes help', '!help memes']):
elif texte == '!memes templates':
return useless.Memes.get_templates()
elif texte == '!memes help':
return useless.Memes.get_help()
elif '!memes ' in texte:
texte = texte.replace('!memes ', '').split(' ; ')
......@@ -187,7 +195,7 @@ class Bot(Client):
self.sendLocalImage(meme.get_result(), thread_id=thread_id, thread_type=thread_type)
sleep(2)
except:
return 'Ya un petit problème dans la plantation...'
return 'Ya un problème dans la plantation...'
elif any(word.lower() in texte.lower() for word in ["let\'s go", "c'est parti", "go ", "allons "]):
return 'é zé bardi !'
......@@ -260,7 +268,7 @@ class Bot(Client):
except:
return 'Houston, on a un problème...'
elif texte == '!about' or texte == '!cyborg':
return 'Hello, je suis A.N.U.B.I.S. A Not Usefull But Intelligent System, créé par le talentueux LawiK aka Wikle aka Cyborg aka Loïc Dub que je vénère !'
return 'Hello, je suis A.N.U.B.I.S. A Not Usefull But Intelligent System, petit frère de nardco créé par le talentueux LawiK aka Wikle aka Cyborg aka Loïc Dub que je vénère !'
# les triggers en tout genre
elif 'Ah' in texte:
......@@ -269,7 +277,7 @@ class Bot(Client):
elif any(word.lower() in texte.lower() for word in Bot.ahah_liste):
return random.choice(Bot.ahah_liste)
elif any(word.lower() in texte.lower() for word in Bot.what_liste):
return random.choice(Bot.what_liste)
return random.choice(Bot.what_liste) + '?!'
# doit rester à la fin des elif
elif '!' in texte and not any(word in texte for word in [' ! ', '! ', ' !']):
......
#!/usr/bin/python3
# module qui fait des memes
# TODO: a google drive feature where you can upload new templates
# -*- coding: utf-8 -*-
import PIL
from PIL import ImageFont
from PIL import Image
......@@ -119,7 +121,11 @@ class Memes(object):
@classmethod
def get_templates(self):
return 'Faut apprendre à lire un man les gars :\n !memes image_name_or_url ; texte1(OBLIGATOIRE) ; texte2(facultatif)\n\n sinon tu peux voir les templates ici : shorturl.at/bcjA8\n\n Tiens voilà la liste de mes images préenregistrées :\n' + "\n".join(Memes.images.keys())
return 'Tiens voilà la liste de mes images préenregistrées :\n' + "\n".join(Memes.images.keys())
@classmethod
def get_help(self):
return 'Faut apprendre à lire un man les gars :\n !memes image_name_or_url ; texte1(OBLIGATOIRE) ; texte2(facultatif)\n\n sinon tu peux voir les templates ici : shorturl.at/bcjA8'
if __name__ == '__main__':
......@@ -128,5 +134,5 @@ if __name__ == '__main__':
try:
meme1 = Memes(image, 'test1 lol !', 'test2 mdr ?')
file = meme1.process()
except:
print('erreur sur ' + image)
except Exception as e:
print('erreur sur %s : %s' % (image, e))
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter