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

implementation du quizz

parent 56396ad9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 64 ajouts et 5 suppressions
......@@ -3,6 +3,7 @@
## 19 aout 2019
**Ajout:**
- script bot.py quasi complet
- quizz marche
---
......
......@@ -8,10 +8,14 @@ import useless
import usefull
import random
from auth_file import USERNAME, PASSWORD
from googletrans import Translator
translator = Translator()
quizz = useless.Quizz()
class Bot(Client):
ahah_liste = ['ahah', 'mdr', 'lol', 'Mort de rire !', 'Trop marrant', 'tu m\'as tué', 'xD', 'PTDR']
what_liste = ['wat', 'What', 'Nani', 'keske', 'dafuk', 'da fuk']
def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs):
self.markAsDelivered(thread_id, message_object.uid)
......@@ -22,12 +26,12 @@ class Bot(Client):
if 'Ah' in message_object.text:
self.sendLocalImage('images/ah.png', thread_id=thread_id, thread_type=thread_type)
to_send = Bot.tests(message_object.text, self.fetchThreadInfo(thread_id)[thread_id].name)
to_send = Bot.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:
self.send(Message('BOT :' + to_send), thread_id=thread_id, thread_type=thread_type)
@classmethod
def tests(self, texte, channel=''):
def tests(self, texte, thread_id, thread_type, author_id, channel=''):
if texte == '!help':
help_text = 'Ce que je sais faire :\n \
!meteo <ville> ; <pays> ; <dans_n_heure(facultatif)>\n \
......@@ -35,16 +39,26 @@ class Bot(Client):
!useless \n \
!chuck \n\
!nordpress \n \
!quizz [start|new|reset|scoreboard] , not yet implemented\n \
!quizz [start|new|reset|scoreboard|indice|round|question] ... not yet implemented\n \
!q <reponse> pour répondre au quizz\n\
!haddock \n \
!philo \n \
!pipo\n \
!rename <personne> ; <pseudo> \n\
!kohlanta <nom>\n \
!rateau \n \
!maps <nom_du_lieu> <destination(facultatif)>, not yet fully fonctionnal\n \
!maps <nom_du_lieu> <destination(facultatif)> ... not yet fully fonctionnal\n \
!memes <image_name_or_url> ; <texte1> ; <texte2(facultatif)> ... not yet implemented\n\
!ping \n\
!translate <phrase> ; <lang_source> ; <lang_dest>\n\
!about -> vas-y test-moi !\n'
return help_text
if '!translate' in texte:
texte = texte.replace('!translate ', '').split(' ; ')
try:
translator.translate(text=texte[0], dest=texte[2], src=texte[1])
except:
return 'Tiens j\'y arrive pas, Apparement, ça ne marche pas comme ça.'
if texte == '!useless':
return useless.useless()
if texte == '!nordpress':
......@@ -55,6 +69,24 @@ class Bot(Client):
return useless.genererSujet()
if texte == '!haddock':
return useless.haddock()
if '!rename' in texte:
texte = texte.replace('!rename ', '').split(';')
for user in self.fetchAllUsersFromThreads([thread_id]):
if user.name == texte[0]:
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...'])
if any(word.lower() in texte.lower() for word in Bot.what_liste):
return random.choice(Bot.what_liste)
if '!memes ' in texte:
texte = texte.replace('!memes ', '').split(' ; ')
useless.memes(texte)
self.sendLocalImage('meme.png', thread_id=thread_id, thread_type=thread_type)
if any(word.lower() in texte.lower() for word in ["let\'s go", "c'est parti", "go ", "allons "]):
return 'é zé bardi !'
if any(word.lower() in texte.lower() for word in ['noice ', 'nice ', 'ok']):
# self.send(Message(text="👍", emoji_size=EmojiSize.LARGE), thread_id=thread_id, thread_type=thread_type)
self.send(Message(emoji_size=EmojiSize.LARGE), thread_id=thread_id, thread_type=thread_type)
if '!kohlanta' in texte:
texte = texte.replace('!kohlanta ', '')
return useless.kohlanta(texte, channel)
......@@ -66,15 +98,41 @@ class Bot(Client):
return random.choice(Bot.ahah_liste)
if texte == '!rateau':
return useless.getRateau()
# petit jeu de quizz
if '!quizz' in texte:
if 'start' in texte:
return quizz.start()
if 'new' in texte:
return quizz.new()
if 'scoreboard' in texte:
if texte.replace('!quizz scoreboard ', '') != '':
return quizz.scoreboard(texte.replace('!quizz scoreboard ', ''))
else:
return quizz.scoreboard()
if 'reset' in texte:
return quizz.reset()
if 'indice' in quizz:
return quizz.indice()
if 'round' in texte:
return quizz.get_round()
if 'question' in texte:
return quizz.get_question()
if '!q ' in texte:
return quizz.answer(text.replace('!q ', ''), self.fetchUserInfo(author_id)[author_id].name)
# meteo
if '!meteo' in texte:
try:
texte = texte.replace('!meteo ', '').split(' ; ')
if len(texte) == 2:
return usefull.meteo_de(texte[0], texte[1])
else:
return usefull.meteo_de(texte[0], texte[1], dans_n_heures=texte[2])
return usefull.meteo_de(texte[0], texte[1], dans_n_heures=int(texte[2]))
except:
return 'Ousp, c\'est cassé...'
# wikipédia
if '!wikipedia' in texte:
try:
texte = texte.replace('!wikipedia ', '')
......
images/memes_images/10guy.jpg

22,5 ko

images/memes_images/avengers.jpg

30,3 ko

images/memes_images/badsurprise.jpg

64,3 ko

images/memes_images/boyfriend.jpg

95,9 ko

images/memes_images/depressing.jpg

55,7 ko

images/memes_images/euh.jpg

24,9 ko

images/memes_images/gangbang.jpg

28,2 ko

images/memes_images/godblessings.jpg

57,2 ko

images/memes_images/goodchoice.jpg

56,3 ko

images/memes_images/homer.jpg

66,6 ko

images/memes_images/killyou.jpg

30,2 ko

images/memes_images/maths.jpg

52,4 ko

images/memes_images/mdr.jpg

46,7 ko

images/memes_images/nanithfuck.jpg

25,8 ko

images/memes_images/ohlala.jpg

22,8 ko

images/memes_images/ohlala2.jpg

13,5 ko

images/memes_images/on_the_side/badsurprise.jpg

37,1 ko

images/memes_images/on_the_side/goodchoice.jpg

51,4 ko

0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter