|
|
@ -28,15 +28,9 @@ clock = {} |
|
|
|
|
|
|
|
def horloge_read(): |
|
|
|
global clock |
|
|
|
try: |
|
|
|
with open("horloge", "rb") as fichier: |
|
|
|
loader = pickle.Unpickler(fichier) |
|
|
|
clock = loader.load() |
|
|
|
except: |
|
|
|
if (!fichier.closed): |
|
|
|
fichier.close() |
|
|
|
fichier = open("horloge.txt", "w") |
|
|
|
fichier.close() |
|
|
|
with open("horloge", "rb") as fichier: |
|
|
|
loader = pickle.Unpickler(fichier) |
|
|
|
clock = loader.load() |
|
|
|
|
|
|
|
def signal_handler(signal, frame): |
|
|
|
with open("horloge", "wb") as fichier: |
|
|
@ -600,7 +594,7 @@ def cristal(room, event): |
|
|
|
|
|
|
|
args = event['content']['body'].split() |
|
|
|
args.pop(0) |
|
|
|
if (len(args) < 2 || args[len(args)-1][-1] != '?'): |
|
|
|
if (len(args) < 2 or args[len(args)-1][-1] != '?'): |
|
|
|
room.send_text("Utilisation : !cristal <Quel est votre question?>") |
|
|
|
else: |
|
|
|
args[len(args)-1] = args[len(args)-1][0:-1] |
|
|
@ -608,7 +602,7 @@ def cristal(room, event): |
|
|
|
conj = args[0] |
|
|
|
args.pop(0) |
|
|
|
cle = max(args, key=len) |
|
|
|
if (conj == "Est-ce" || conj == "est-ce"): |
|
|
|
if (conj == "Est-ce" or conj == "est-ce"): |
|
|
|
# traitement Oui/non |
|
|
|
phrases = [] |
|
|
|
phrases.append("Evidemment " + nick + ", qu'est ce que tu croyais?") |
|
|
@ -616,7 +610,7 @@ def cristal(room, event): |
|
|
|
phrases.append("Oui " + nick +", et quelque chose d'encore pire ensuite pour " + cle + "!") |
|
|
|
phrases.append("Je ne sais pas si je dois te le dire au risque de te faire de la peine, " + nick + "...") |
|
|
|
reponses(room, phrases) |
|
|
|
elif (conj == "Combien" || conj == "combien"): |
|
|
|
elif (conj == "Combien" or conj == "combien"): |
|
|
|
# traitement quantité |
|
|
|
phrases = [] |
|
|
|
phrases.append("Enormement " + nick + "!") |
|
|
@ -624,7 +618,7 @@ def cristal(room, event): |
|
|
|
phrases.append("Peu comparé à l'immensité, mais au niveau de " + nick +", forcément...") |
|
|
|
phrases.append("J'en vois des dizaines, des centaines et par un prompt renfort ils furent 500 en arrivant au port!") |
|
|
|
reponses(room, phrases) |
|
|
|
elif (conj == "Pourquoi" || conj == "pourquoi"): |
|
|
|
elif (conj == "Pourquoi" or conj == "pourquoi"): |
|
|
|
# traitement raison |
|
|
|
phrases = [] |
|
|
|
phrases.append("Parce que la vie est injuste " + nick + "!") |
|
|
@ -632,7 +626,7 @@ def cristal(room, event): |
|
|
|
phrases.append("Pour la richesse, pour le pouvoir, pour le pouvoir qu'apporte la richesse.") |
|
|
|
phrases.append("A cause d'une démence aussi soudaine que passagère.") |
|
|
|
reponses(room, phrases) |
|
|
|
elif (conj == "Comment" || conj == "comment"): |
|
|
|
elif (conj == "Comment" or conj == "comment"): |
|
|
|
# traitement methode |
|
|
|
phrases = [] |
|
|
|
phrases.append("Discrètement, sournoisement, vicieusement " + nick + "!") |
|
|
@ -640,7 +634,7 @@ def cristal(room, event): |
|
|
|
phrases.append("Avec un trombone et un élastique, comme McGuy" + nick +"!") |
|
|
|
phrases.append("Avec une aide des plus innattendues.") |
|
|
|
reponses(room, phrases) |
|
|
|
elif (conj == "Quand" || conj == "quand"): |
|
|
|
elif (conj == "Quand" or conj == "quand"): |
|
|
|
# traitement temps |
|
|
|
phrases = [] |
|
|
|
phrases.append("Plus vite que tu ne l'imagine, retourne toi " + nick + "!") |
|
|
@ -648,7 +642,7 @@ def cristal(room, event): |
|
|
|
phrases.append("Pile poil la durée que tu imaginais.") |
|
|
|
phrases.append("Dans plus lontemps que tu ne le pensais, mais tous les intervenants ont une bonne excuse. Leur collègue de droite a merdé.") |
|
|
|
reponses(room, phrases) |
|
|
|
elif (conj == "Où" || conj == "où"): |
|
|
|
elif (conj == "Où" or conj == "où"): |
|
|
|
# traitement lieu |
|
|
|
phrases = [] |
|
|
|
phrases.append("Dans la ville voisine") |
|
|
@ -683,11 +677,11 @@ def horloge(room, event): |
|
|
|
room.send_text(cle[1] + " : \u1F55A \n") if (valeur == 5) |
|
|
|
room.send_text(cle[1] + " : \u1F55B \n") if (valeur == 6) |
|
|
|
room.send_text(cle[1] + " : " + valeur + " \n") if (valeur > 6) |
|
|
|
elif (len(args) >= 2 && args[len(args)-1].isnumeric()): |
|
|
|
elif (len(args) >= 2 and args[len(args)-1].isnumeric()): |
|
|
|
# Place le niveau de l'horloge entre 0 et 6 |
|
|
|
nv = int(args[len(args)-1]) |
|
|
|
clock[room.room_id, args[0:-1]] = nv |
|
|
|
elif (len(args) >= 2 && args[0] == "del"): |
|
|
|
elif (len(args) >= 2 and args[0] == "del"): |
|
|
|
# Supprime une horloge |
|
|
|
args.pop(0) |
|
|
|
clock.pop(room.room_id, args) |
|
|
|