Changing sender to nick in modules
This commit is contained in:
parent
93d623e241
commit
14a963871f
@ -48,6 +48,8 @@ def parseanswer (msg):
|
|||||||
if res is not None:
|
if res is not None:
|
||||||
if res.group(2) == "sender":
|
if res.group(2) == "sender":
|
||||||
cnt[i] = msg.sender
|
cnt[i] = msg.sender
|
||||||
|
elif res.group(2) == "nick":
|
||||||
|
cnt[i] = msg.nick
|
||||||
elif res.group(2) == "chan" or res.group(2) == "channel":
|
elif res.group(2) == "chan" or res.group(2) == "channel":
|
||||||
cnt[i] = msg.channel
|
cnt[i] = msg.channel
|
||||||
elif res.group(2) == "date":
|
elif res.group(2) == "date":
|
||||||
@ -75,7 +77,7 @@ def parseask (msg):
|
|||||||
alias = ModuleState("alias")
|
alias = ModuleState("alias")
|
||||||
alias["alias"] = result.group(1)
|
alias["alias"] = result.group(1)
|
||||||
alias["origin"] = result.group(3)
|
alias["origin"] = result.group(3)
|
||||||
alias["creator"] = msg.sender
|
alias["creator"] = msg.nick
|
||||||
DATAS.getNode("aliases").addChild(alias)
|
DATAS.getNode("aliases").addChild(alias)
|
||||||
msg.send_snd("Nouvel alias %s défini avec succès." % result.group(1))
|
msg.send_snd("Nouvel alias %s défini avec succès." % result.group(1))
|
||||||
save()
|
save()
|
||||||
|
@ -23,12 +23,12 @@ def help_full ():
|
|||||||
return "!anniv /who/: gives the remaining time before the anniversary of /who/\n!age /who/: gives the age of /who/\nIf /who/ is not given, gives the remaining time before your anniversary.\n\n To set yout birthday, say it to nemubot :)"
|
return "!anniv /who/: gives the remaining time before the anniversary of /who/\n!age /who/: gives the age of /who/\nIf /who/ is not given, gives the remaining time before your anniversary.\n\n To set yout birthday, say it to nemubot :)"
|
||||||
|
|
||||||
|
|
||||||
def findName(msg):
|
def findName(msg):
|
||||||
if len(msg.cmd) < 2 or msg.cmd[1].lower() == "moi" or msg.cmd[1].lower() == "me":
|
if len(msg.cmd) < 2 or msg.cmd[1].lower() == "moi" or msg.cmd[1].lower() == "me":
|
||||||
name = msg.sender.lower()
|
name = msg.nick.lower()
|
||||||
else:
|
else:
|
||||||
name = msg.cmd[1].lower()
|
name = msg.cmd[1].lower()
|
||||||
|
|
||||||
matches = []
|
matches = []
|
||||||
|
|
||||||
if name in DATAS.index:
|
if name in DATAS.index:
|
||||||
@ -38,7 +38,7 @@ def findName(msg):
|
|||||||
if k.find (name) == 0:
|
if k.find (name) == 0:
|
||||||
matches.append (k)
|
matches.append (k)
|
||||||
return (matches, name)
|
return (matches, name)
|
||||||
|
|
||||||
|
|
||||||
def parseanswer(msg):
|
def parseanswer(msg):
|
||||||
if msg.cmd[0] == "anniv":
|
if msg.cmd[0] == "anniv":
|
||||||
@ -56,7 +56,7 @@ def parseanswer(msg):
|
|||||||
|
|
||||||
msg.send_chn (msg.countdown_format (tyd, "Il reste %s avant l'anniversaire de %s !" % ("%s", name), ""))
|
msg.send_chn (msg.countdown_format (tyd, "Il reste %s avant l'anniversaire de %s !" % ("%s", name), ""))
|
||||||
else:
|
else:
|
||||||
msg.send_chn ("%s: désolé, je ne connais pas la date d'anniversaire de %s. Quand est-il né ?"%(msg.sender, name))
|
msg.send_chn ("%s: désolé, je ne connais pas la date d'anniversaire de %s. Quand est-il né ?"%(msg.nick, name))
|
||||||
return True
|
return True
|
||||||
elif msg.cmd[0] == "age":
|
elif msg.cmd[0] == "age":
|
||||||
(matches, name) = findName(msg)
|
(matches, name) = findName(msg)
|
||||||
@ -66,7 +66,7 @@ def parseanswer(msg):
|
|||||||
|
|
||||||
msg.send_chn (msg.countdown_format (d, "", "%s a %s." % (n, "%s")))
|
msg.send_chn (msg.countdown_format (d, "", "%s a %s." % (n, "%s")))
|
||||||
else:
|
else:
|
||||||
msg.send_chn ("%s: désolé, je ne connais pas l'âge de %s. Quand est-il né ?"%(msg.sender, name))
|
msg.send_chn ("%s: désolé, je ne connais pas l'âge de %s. Quand est-il né ?"%(msg.nick, name))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -77,19 +77,19 @@ def parseask(msg):
|
|||||||
try:
|
try:
|
||||||
extDate = msg.extractDate ()
|
extDate = msg.extractDate ()
|
||||||
if extDate is None:
|
if extDate is None:
|
||||||
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.sender))
|
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.nick))
|
||||||
else:
|
else:
|
||||||
if msg.sender.lower() in DATAS.index:
|
if msg.nick.lower() in DATAS.index:
|
||||||
DATAS.index[msg.sender.lower()] = extDate
|
DATAS.index[msg.nick.lower()] = extDate
|
||||||
else:
|
else:
|
||||||
ms = ModuleState("birthday")
|
ms = ModuleState("birthday")
|
||||||
ms.setAttribute("name", msg.sender.lower())
|
ms.setAttribute("name", msg.nick.lower())
|
||||||
ms.setAttribute("born", extDate)
|
ms.setAttribute("born", extDate)
|
||||||
DATAS.addChild(ms)
|
DATAS.addChild(ms)
|
||||||
msg.send_chn ("%s: ok, c'est noté, ta date de naissance est le %s" % (msg.sender, extDate.strftime("%A %d %B %Y à %H:%M")))
|
msg.send_chn ("%s: ok, c'est noté, ta date de naissance est le %s" % (msg.nick, extDate.strftime("%A %d %B %Y à %H:%M")))
|
||||||
save()
|
save()
|
||||||
except:
|
except:
|
||||||
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.sender))
|
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.nick))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ def parseanswer(msg):
|
|||||||
strnd = ModuleState("strend")
|
strnd = ModuleState("strend")
|
||||||
strnd["server"] = msg.srv.id
|
strnd["server"] = msg.srv.id
|
||||||
strnd["channel"] = msg.channel
|
strnd["channel"] = msg.channel
|
||||||
strnd["proprio"] = msg.sender
|
strnd["proprio"] = msg.nick
|
||||||
strnd["start"] = datetime.now()
|
strnd["start"] = datetime.now()
|
||||||
strnd["name"] = msg.cmd[1]
|
strnd["name"] = msg.cmd[1]
|
||||||
DATAS.addChild(strnd)
|
DATAS.addChild(strnd)
|
||||||
|
|
||||||
if len(msg.cmd) > 2:
|
if len(msg.cmd) > 2:
|
||||||
result = re.match("([0-9]+)([smhdjSMHDJ])?", msg.cmd[2])
|
result = re.match("([0-9]+)([smhdjSMHDJ])?", msg.cmd[2])
|
||||||
if result is not None:
|
if result is not None:
|
||||||
@ -101,7 +101,7 @@ def parseanswer(msg):
|
|||||||
elif (msg.cmd[0] == "end" or msg.cmd[0] == "forceend") and len(msg.cmd) > 1:
|
elif (msg.cmd[0] == "end" or msg.cmd[0] == "forceend") and len(msg.cmd) > 1:
|
||||||
if msg.cmd[1] in DATAS.index:
|
if msg.cmd[1] in DATAS.index:
|
||||||
msg.send_chn ("%s a duré %s." % (msg.cmd[1], msg.just_countdown(datetime.now () - DATAS.index[msg.cmd[1]].getDate("start"))))
|
msg.send_chn ("%s a duré %s." % (msg.cmd[1], msg.just_countdown(datetime.now () - DATAS.index[msg.cmd[1]].getDate("start"))))
|
||||||
if DATAS.index[msg.cmd[1]]["proprio"] == msg.sender or (msg.cmd[0] == "forceend" and msg.sender == msg.srv.owner):
|
if DATAS.index[msg.cmd[1]]["proprio"] == msg.nick or (msg.cmd[0] == "forceend" and msg.nick == msg.srv.owner):
|
||||||
DATAS.delChild(DATAS.index[msg.cmd[1]])
|
DATAS.delChild(DATAS.index[msg.cmd[1]])
|
||||||
Manager.newStrendEvt.set()
|
Manager.newStrendEvt.set()
|
||||||
save()
|
save()
|
||||||
@ -148,7 +148,7 @@ def parseask(msg):
|
|||||||
evt = ModuleState("event")
|
evt = ModuleState("event")
|
||||||
evt["server"] = msg.srv.id
|
evt["server"] = msg.srv.id
|
||||||
evt["channel"] = msg.channel
|
evt["channel"] = msg.channel
|
||||||
evt["proprio"] = msg.sender
|
evt["proprio"] = msg.nick
|
||||||
evt["name"] = name.group(1)
|
evt["name"] = name.group(1)
|
||||||
evt["start"] = extDate
|
evt["start"] = extDate
|
||||||
evt["msg_after"] = msg_after
|
evt["msg_after"] = msg_after
|
||||||
@ -162,7 +162,7 @@ def parseask(msg):
|
|||||||
evt = ModuleState("event")
|
evt = ModuleState("event")
|
||||||
evt["server"] = msg.srv.id
|
evt["server"] = msg.srv.id
|
||||||
evt["channel"] = msg.channel
|
evt["channel"] = msg.channel
|
||||||
evt["proprio"] = msg.sender
|
evt["proprio"] = msg.nick
|
||||||
evt["name"] = name.group(1)
|
evt["name"] = name.group(1)
|
||||||
evt["msg_before"] = texts.group (2)
|
evt["msg_before"] = texts.group (2)
|
||||||
DATAS.addChild(evt)
|
DATAS.addChild(evt)
|
||||||
|
@ -44,8 +44,8 @@ class Session:
|
|||||||
if nextQ is not None:
|
if nextQ is not None:
|
||||||
if self.channel == self.server.nick:
|
if self.channel == self.server.nick:
|
||||||
self.server.send_msg_final(self.sender, "%s%s" % (bfr, nextQ.question))
|
self.server.send_msg_final(self.sender, "%s%s" % (bfr, nextQ.question))
|
||||||
elif self.sender != self.channel:
|
elif self.sender.split("!")[0] != self.channel:
|
||||||
self.server.send_msg_final(self.channel, "%s: %s%s" % (self.sender, bfr, nextQ.question))
|
self.server.send_msg_final(self.channel, "%s: %s%s" % (self.sender.split("!")[0], bfr, nextQ.question))
|
||||||
else:
|
else:
|
||||||
self.server.send_msg_final(self.channel, "%s%s" % (bfr, nextQ.question))
|
self.server.send_msg_final(self.channel, "%s%s" % (bfr, nextQ.question))
|
||||||
else:
|
else:
|
||||||
|
@ -73,28 +73,28 @@ def buildSession(msg, categ = None, nbQuest = 10, channel = False):
|
|||||||
if channel:
|
if channel:
|
||||||
Session.SESSIONS[msg.channel] = sess
|
Session.SESSIONS[msg.channel] = sess
|
||||||
else:
|
else:
|
||||||
Session.SESSIONS[msg.sender] = sess
|
Session.SESSIONS[msg.realname] = sess
|
||||||
|
|
||||||
|
|
||||||
def askQuestion(msg, bfr = ""):
|
def askQuestion(msg, bfr = ""):
|
||||||
Session.SESSIONS[msg.sender].askNext(bfr)
|
Session.SESSIONS[msg.realname].askNext(bfr)
|
||||||
|
|
||||||
def parseanswer(msg):
|
def parseanswer(msg):
|
||||||
global DATAS
|
global DATAS
|
||||||
if msg.cmd[0] == "qcm" or msg.cmd[0] == "qcmchan" or msg.cmd[0] == "simulateqcm":
|
if msg.cmd[0] == "qcm" or msg.cmd[0] == "qcmchan" or msg.cmd[0] == "simulateqcm":
|
||||||
if msg.sender in Session.SESSIONS:
|
if msg.realname in Session.SESSIONS:
|
||||||
if len(msg.cmd) > 1:
|
if len(msg.cmd) > 1:
|
||||||
if msg.cmd[1] == "stop" or msg.cmd[1] == "end":
|
if msg.cmd[1] == "stop" or msg.cmd[1] == "end":
|
||||||
sess = Session.SESSIONS[msg.sender]
|
sess = Session.SESSIONS[msg.realname]
|
||||||
if sess.good > 1: goodS = "s"
|
if sess.good > 1: goodS = "s"
|
||||||
else: goodS = ""
|
else: goodS = ""
|
||||||
msg.send_chn("%s: Fini, tu as donné %d bonne%s réponse%s sur %d questions." % (msg.sender, sess.good, goodS, goodS, sess.current))
|
msg.send_chn("%s: Fini, tu as donné %d bonne%s réponse%s sur %d questions." % (msg.nick, sess.good, goodS, goodS, sess.current))
|
||||||
del Session.SESSIONS[msg.sender]
|
del Session.SESSIONS[msg.realname]
|
||||||
return True
|
return True
|
||||||
elif msg.cmd[1] == "next" or msg.cmd[1] == "suivant" or msg.cmd[1] == "suivante":
|
elif msg.cmd[1] == "next" or msg.cmd[1] == "suivant" or msg.cmd[1] == "suivante":
|
||||||
askQuestion(msg)
|
askQuestion(msg)
|
||||||
return True
|
return True
|
||||||
msg.send_chn("%s: tu as déjà une session de QCM en cours, finis-la avant d'en commencer une nouvelle." % msg.sender)
|
msg.send_chn("%s: tu as déjà une session de QCM en cours, finis-la avant d'en commencer une nouvelle." % msg.nick)
|
||||||
elif msg.channel in Session.SESSIONS:
|
elif msg.channel in Session.SESSIONS:
|
||||||
if len(msg.cmd) > 1:
|
if len(msg.cmd) > 1:
|
||||||
if msg.cmd[1] == "stop" or msg.cmd[1] == "end":
|
if msg.cmd[1] == "stop" or msg.cmd[1] == "end":
|
||||||
@ -128,19 +128,19 @@ def parseanswer(msg):
|
|||||||
elif msg.cmd[0] == "qcmchan":
|
elif msg.cmd[0] == "qcmchan":
|
||||||
Session.SESSIONS[msg.channel].askNext()
|
Session.SESSIONS[msg.channel].askNext()
|
||||||
else:
|
else:
|
||||||
msg.send_chn("QCM de %d questions" % len(Session.SESSIONS[msg.sender].questions))
|
msg.send_chn("QCM de %d questions" % len(Session.SESSIONS[msg.realname].questions))
|
||||||
del Session.SESSIONS[msg.sender]
|
del Session.SESSIONS[msg.realname]
|
||||||
return True
|
return True
|
||||||
elif msg.sender in Session.SESSIONS:
|
elif msg.realname in Session.SESSIONS:
|
||||||
if msg.cmd[0] == "info" or msg.cmd[0] == "infoquestion":
|
if msg.cmd[0] == "info" or msg.cmd[0] == "infoquestion":
|
||||||
msg.send_chn("Cette question a été écrite par %s et validée par %s, le %s" % Session.SESSIONS[msg.sender].question.tupleInfo)
|
msg.send_chn("Cette question a été écrite par %s et validée par %s, le %s" % Session.SESSIONS[msg.realname].question.tupleInfo)
|
||||||
return True
|
return True
|
||||||
elif msg.cmd[0] == "report" or msg.cmd[0] == "reportquestion":
|
elif msg.cmd[0] == "report" or msg.cmd[0] == "reportquestion":
|
||||||
if len(msg.cmd) == 1:
|
if len(msg.cmd) == 1:
|
||||||
msg.send_chn("Veuillez indiquer une raison de report")
|
msg.send_chn("Veuillez indiquer une raison de report")
|
||||||
elif Session.SESSIONS[msg.sender].question.report(' '.join(msg.cmd[1:])):
|
elif Session.SESSIONS[msg.realname].question.report(' '.join(msg.cmd[1:])):
|
||||||
msg.send_chn("Cette question vient d'être signalée.")
|
msg.send_chn("Cette question vient d'être signalée.")
|
||||||
Session.SESSIONS[msg.sender].askNext()
|
Session.SESSIONS[msg.realname].askNext()
|
||||||
else:
|
else:
|
||||||
msg.send_chn("Une erreur s'est produite lors du signalement de la question, veuillez recommencer plus tard.")
|
msg.send_chn("Une erreur s'est produite lors du signalement de la question, veuillez recommencer plus tard.")
|
||||||
return True
|
return True
|
||||||
@ -173,8 +173,8 @@ def parseanswer(msg):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def parseask(msg):
|
def parseask(msg):
|
||||||
if msg.sender in Session.SESSIONS:
|
if msg.realname in Session.SESSIONS:
|
||||||
dest = msg.sender
|
dest = msg.realname
|
||||||
|
|
||||||
if Session.SESSIONS[dest].question.isCorrect(msg.content):
|
if Session.SESSIONS[dest].question.isCorrect(msg.content):
|
||||||
Session.SESSIONS[dest].good += 1
|
Session.SESSIONS[dest].good += 1
|
||||||
@ -184,7 +184,7 @@ def parseask(msg):
|
|||||||
Session.SESSIONS[dest].bad += 1
|
Session.SESSIONS[dest].bad += 1
|
||||||
if Session.SESSIONS[dest].trys == 0:
|
if Session.SESSIONS[dest].trys == 0:
|
||||||
Session.SESSIONS[dest].trys = 1
|
Session.SESSIONS[dest].trys = 1
|
||||||
msg.send_chn("%s: non, essaie encore :p" % msg.sender)
|
msg.send_chn("%s: non, essaie encore :p" % msg.nick)
|
||||||
else:
|
else:
|
||||||
askQuestion(msg, "non, la bonne reponse était : %s ; " % Session.SESSIONS[dest].question.bestAnswer)
|
askQuestion(msg, "non, la bonne reponse était : %s ; " % Session.SESSIONS[dest].question.bestAnswer)
|
||||||
return True
|
return True
|
||||||
@ -195,10 +195,10 @@ def parseask(msg):
|
|||||||
if Session.SESSIONS[dest].question.isCorrect(msg.content):
|
if Session.SESSIONS[dest].question.isCorrect(msg.content):
|
||||||
Session.SESSIONS[dest].good += 1
|
Session.SESSIONS[dest].good += 1
|
||||||
Session.SESSIONS[dest].score += Session.SESSIONS[dest].question.getScore(msg.content)
|
Session.SESSIONS[dest].score += Session.SESSIONS[dest].question.getScore(msg.content)
|
||||||
msg.send_chn("%s: correct :)" % msg.sender)
|
msg.send_chn("%s: correct :)" % msg.nick)
|
||||||
Session.SESSIONS[dest].prepareNext()
|
Session.SESSIONS[dest].prepareNext()
|
||||||
else:
|
else:
|
||||||
Session.SESSIONS[dest].bad += 1
|
Session.SESSIONS[dest].bad += 1
|
||||||
msg.send_chn("%s: non, essaie encore :p" % msg.sender)
|
msg.send_chn("%s: non, essaie encore :p" % msg.nick)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -39,21 +39,21 @@ class GameUpdater(threading.Thread):
|
|||||||
question = QUESTIONS[quest]["question"]
|
question = QUESTIONS[quest]["question"]
|
||||||
regexp = QUESTIONS[quest]["regexp"]
|
regexp = QUESTIONS[quest]["regexp"]
|
||||||
great = QUESTIONS[quest]["great"]
|
great = QUESTIONS[quest]["great"]
|
||||||
self.msg.send_chn("%s: %s" % (self.msg.sender, question))
|
self.msg.send_chn("%s: %s" % (self.msg.nick, question))
|
||||||
|
|
||||||
DELAYED[self.msg.sender] = DelayedTuple(regexp, great)
|
DELAYED[self.msg.nick] = DelayedTuple(regexp, great)
|
||||||
|
|
||||||
DELAYED[self.msg.sender].wait(20)
|
DELAYED[self.msg.nick].wait(20)
|
||||||
|
|
||||||
if DELAYED[self.msg.sender].triche(DELAYED[self.msg.sender].msg):
|
if DELAYED[self.msg.nick].triche(DELAYED[self.msg.nick].msg):
|
||||||
getUser(self.msg.sender).playTriche()
|
getUser(self.msg.nick).playTriche()
|
||||||
self.msg.send_chn("%s: Tricheur !" % self.msg.sender)
|
self.msg.send_chn("%s: Tricheur !" % self.msg.nick)
|
||||||
elif DELAYED[self.msg.sender].perfect(DELAYED[self.msg.sender].msg):
|
elif DELAYED[self.msg.nick].perfect(DELAYED[self.msg.nick].msg):
|
||||||
if random.randint(0, 10) == 1:
|
if random.randint(0, 10) == 1:
|
||||||
getUser(self.msg.sender).bonusQuestion()
|
getUser(self.msg.nick).bonusQuestion()
|
||||||
self.msg.send_chn("%s: Correct !" % self.msg.sender)
|
self.msg.send_chn("%s: Correct !" % self.msg.nick)
|
||||||
else:
|
else:
|
||||||
self.msg.send_chn("%s: J'accepte" % self.msg.sender)
|
self.msg.send_chn("%s: J'accepte" % self.msg.nick)
|
||||||
del DELAYED[self.msg.sender]
|
del DELAYED[self.msg.nick]
|
||||||
SCORES.save(self.msg.sender)
|
SCORES.save(self.msg.nick)
|
||||||
save()
|
save()
|
||||||
|
@ -86,7 +86,7 @@ def parseanswer (msg):
|
|||||||
|
|
||||||
def win(msg):
|
def win(msg):
|
||||||
global SCORES
|
global SCORES
|
||||||
who = msg.sender
|
who = msg.nick
|
||||||
|
|
||||||
manche = DATAS.getNode("manche")
|
manche = DATAS.getNode("manche")
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ def win(msg):
|
|||||||
|
|
||||||
def parseask (msg):
|
def parseask (msg):
|
||||||
if len(GameUpdater.DELAYED) > 0:
|
if len(GameUpdater.DELAYED) > 0:
|
||||||
if msg.sender in GameUpdater.DELAYED:
|
if msg.nick in GameUpdater.DELAYED:
|
||||||
GameUpdater.DELAYED[msg.sender].msg = msg.content
|
GameUpdater.DELAYED[msg.nick].msg = msg.content
|
||||||
GameUpdater.DELAYED[msg.sender].delayEvnt.set()
|
GameUpdater.DELAYED[msg.nick].delayEvnt.set()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -142,82 +142,82 @@ def getUser(name):
|
|||||||
if name not in SCORES:
|
if name not in SCORES:
|
||||||
SCORES[name] = Score.Score()
|
SCORES[name] = Score.Score()
|
||||||
return SCORES[name]
|
return SCORES[name]
|
||||||
|
|
||||||
|
|
||||||
def parselisten (msg):
|
def parselisten (msg):
|
||||||
if len(GameUpdater.DELAYED) > 0 and msg.sender in GameUpdater.DELAYED and GameUpdater.DELAYED[msg.sender].good(msg.content):
|
if len(GameUpdater.DELAYED) > 0 and msg.nick in GameUpdater.DELAYED and GameUpdater.DELAYED[msg.nick].good(msg.content):
|
||||||
msg.send_chn("%s: n'oublie pas le nemubot: devant ta réponse pour qu'elle soit prise en compte !" % msg.sender)
|
msg.send_chn("%s: n'oublie pas le nemubot: devant ta réponse pour qu'elle soit prise en compte !" % msg.nick)
|
||||||
|
|
||||||
bfrseen = None
|
bfrseen = None
|
||||||
if msg.realname in LASTSEEN:
|
if msg.realname in LASTSEEN:
|
||||||
bfrseen = LASTSEEN[msg.realname]
|
bfrseen = LASTSEEN[msg.realname]
|
||||||
LASTSEEN[msg.realname] = datetime.now()
|
LASTSEEN[msg.realname] = datetime.now()
|
||||||
|
|
||||||
# if msg.channel == "#nemutest" and msg.sender not in GameUpdater.DELAYED:
|
# if msg.channel == "#nemutest" and msg.nick not in GameUpdater.DELAYED:
|
||||||
if msg.channel != "#nemutest" and msg.sender not in GameUpdater.DELAYED:
|
if msg.channel != "#nemutest" and msg.nick not in GameUpdater.DELAYED:
|
||||||
|
|
||||||
if re.match("^(42|quarante[- ]?deux).{,2}$", msg.content.strip().lower()):
|
if re.match("^(42|quarante[- ]?deux).{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.minute == 10 and msg.time.second == 10 and msg.time.hour == 10:
|
if msg.time.minute == 10 and msg.time.second == 10 and msg.time.hour == 10:
|
||||||
getUser(msg.sender).playTen()
|
getUser(msg.nick).playTen()
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
elif msg.time.minute == 42:
|
elif msg.time.minute == 42:
|
||||||
if msg.time.second == 0:
|
if msg.time.second == 0:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playFtt()
|
getUser(msg.nick).playFtt()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^(23|vingt[ -]?trois).{,2}$", msg.content.strip().lower()):
|
if re.match("^(23|vingt[ -]?trois).{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.minute == 23:
|
if msg.time.minute == 23:
|
||||||
if msg.time.second == 0:
|
if msg.time.second == 0:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playTwt()
|
getUser(msg.nick).playTwt()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^(10){3}.{,2}$", msg.content.strip().lower()):
|
if re.match("^(10){3}.{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.minute == 10 and msg.time.hour == 10:
|
if msg.time.minute == 10 and msg.time.hour == 10:
|
||||||
if msg.time.second == 10:
|
if msg.time.second == 10:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playTen()
|
getUser(msg.nick).playTen()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^0?12345.{,2}$", msg.content.strip().lower()):
|
if re.match("^0?12345.{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.hour == 1 and msg.time.minute == 23 and (msg.time.second == 45 or (msg.time.second == 46 and msg.time.microsecond < 330000)):
|
if msg.time.hour == 1 and msg.time.minute == 23 and (msg.time.second == 45 or (msg.time.second == 46 and msg.time.microsecond < 330000)):
|
||||||
getUser(msg.sender).playSuite()
|
getUser(msg.nick).playSuite()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^[1l][e3]{2}[t7] ?t?ime.{,2}$", msg.content.strip().lower()):
|
if re.match("^[1l][e3]{2}[t7] ?t?ime.{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.hour == 13 and msg.time.minute == 37:
|
if msg.time.hour == 13 and msg.time.minute == 37:
|
||||||
if msg.time.second == 0:
|
if msg.time.second == 0:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playLeet()
|
getUser(msg.nick).playLeet()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^(pi|3.14) ?time.{,2}$", msg.content.strip().lower()):
|
if re.match("^(pi|3.14) ?time.{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.hour == 3 and msg.time.minute == 14:
|
if msg.time.hour == 3 and msg.time.minute == 14:
|
||||||
if msg.time.second == 15 or msg.time.second == 16:
|
if msg.time.second == 15 or msg.time.second == 16:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playPi()
|
getUser(msg.nick).playPi()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if re.match("^(404( ?time)?|time ?not ?found).{,2}$", msg.content.strip().lower()):
|
if re.match("^(404( ?time)?|time ?not ?found).{,2}$", msg.content.strip().lower()):
|
||||||
if msg.time.hour == 4 and msg.time.minute == 4:
|
if msg.time.hour == 4 and msg.time.minute == 4:
|
||||||
if msg.time.second == 0 or msg.time.second == 4:
|
if msg.time.second == 0 or msg.time.second == 4:
|
||||||
getUser(msg.sender).playGreat()
|
getUser(msg.nick).playGreat()
|
||||||
getUser(msg.sender).playNotfound()
|
getUser(msg.nick).playNotfound()
|
||||||
else:
|
else:
|
||||||
getUser(msg.sender).playBad()
|
getUser(msg.nick).playBad()
|
||||||
|
|
||||||
if getUser(msg.sender).isWinner():
|
if getUser(msg.nick).isWinner():
|
||||||
print ("Nous avons un vainqueur ! Nouvelle manche :p")
|
print ("Nous avons un vainqueur ! Nouvelle manche :p")
|
||||||
win(msg)
|
win(msg)
|
||||||
return True
|
return True
|
||||||
elif getUser(msg.sender).hasChanged():
|
elif getUser(msg.nick).hasChanged():
|
||||||
gu = GameUpdater.GameUpdater(msg, bfrseen)
|
gu = GameUpdater.GameUpdater(msg, bfrseen)
|
||||||
gu.start()
|
gu.start()
|
||||||
return True
|
return True
|
||||||
|
@ -40,7 +40,7 @@ def parseanswer(msg):
|
|||||||
|
|
||||||
|
|
||||||
def parseask(msg):
|
def parseask(msg):
|
||||||
if len(DELAYED) > 0 and msg.sender == msg.srv.partner:
|
if len(DELAYED) > 0 and msg.nick == msg.srv.partner:
|
||||||
treat = False
|
treat = False
|
||||||
for part in msg.content.split(';'):
|
for part in msg.content.split(';'):
|
||||||
if part is None:
|
if part is None:
|
||||||
@ -74,7 +74,7 @@ def startSoutenance (msg):
|
|||||||
else:
|
else:
|
||||||
avre = "%s *d'avance*"%msg.just_countdown(soutenance.hour - soutenance.start, 4)
|
avre = "%s *d'avance*"%msg.just_countdown(soutenance.hour - soutenance.start, 4)
|
||||||
msg.send_chn ("Actuellement à la soutenance numéro %d, commencée il y a %s avec %s."%(soutenance.rank, msg.just_countdown(datetime.now () - soutenance.start, 4), avre))
|
msg.send_chn ("Actuellement à la soutenance numéro %d, commencée il y a %s avec %s."%(soutenance.rank, msg.just_countdown(datetime.now () - soutenance.start, 4), avre))
|
||||||
|
|
||||||
elif msg.cmd[1] == "assistants" or msg.cmd[1] == "assistant" or msg.cmd[1] == "yaka" or msg.cmd[1] == "yakas" or msg.cmd[1] == "acu" or msg.cmd[1] == "acus":
|
elif msg.cmd[1] == "assistants" or msg.cmd[1] == "assistant" or msg.cmd[1] == "yaka" or msg.cmd[1] == "yakas" or msg.cmd[1] == "acu" or msg.cmd[1] == "acus":
|
||||||
assistants = datas.findAssistants()
|
assistants = datas.findAssistants()
|
||||||
if len(assistants) > 0:
|
if len(assistants) > 0:
|
||||||
|
@ -50,15 +50,15 @@ def station_status(msg, station):
|
|||||||
free = int(free[0].childNodes[0].nodeValue)
|
free = int(free[0].childNodes[0].nodeValue)
|
||||||
else:
|
else:
|
||||||
free = 0
|
free = 0
|
||||||
msg.send_chn("%s: à la station %s : %d vélib et %d points d'attache disponibles." % (msg.sender, station, available, free))
|
msg.send_chn("%s: à la station %s : %d vélib et %d points d'attache disponibles." % (msg.nick, station, available, free))
|
||||||
else:
|
else:
|
||||||
msg.send_chn("%s: station %s inconnue." % (msg.sender, station))
|
msg.send_chn("%s: station %s inconnue." % (msg.nick, station))
|
||||||
|
|
||||||
def parseanswer(msg):
|
def parseanswer(msg):
|
||||||
global DATAS
|
global DATAS
|
||||||
if msg.cmd[0] == "velib":
|
if msg.cmd[0] == "velib":
|
||||||
if len(msg.cmd) > 5:
|
if len(msg.cmd) > 5:
|
||||||
msg.send_chn("%s: Demande-moi moins de stations à la fois." % msg.sender)
|
msg.send_chn("%s: Demande-moi moins de stations à la fois." % msg.nick)
|
||||||
elif len(msg.cmd) > 1:
|
elif len(msg.cmd) > 1:
|
||||||
for station in msg.cmd[1:]:
|
for station in msg.cmd[1:]:
|
||||||
if re.match("^[0-9]{4,5}$", station):
|
if re.match("^[0-9]{4,5}$", station):
|
||||||
@ -66,9 +66,9 @@ def parseanswer(msg):
|
|||||||
elif station in DATAS.index:
|
elif station in DATAS.index:
|
||||||
station_status(msg, DATAS.index[station]["number"])
|
station_status(msg, DATAS.index[station]["number"])
|
||||||
else:
|
else:
|
||||||
msg.send_chn("%s: numéro de station invalide." % (msg.sender))
|
msg.send_chn("%s: numéro de station invalide." % (msg.nick))
|
||||||
else:
|
else:
|
||||||
msg.send_chn("%s: Pour quelle station ?" % msg.sender)
|
msg.send_chn("%s: Pour quelle station ?" % msg.nick)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -96,7 +96,7 @@ def whoison(msg):
|
|||||||
else:
|
else:
|
||||||
msg.send_chn ("%s: %d personnes" % (pb, len(found)))
|
msg.send_chn ("%s: %d personnes" % (pb, len(found)))
|
||||||
else:
|
else:
|
||||||
msg.send_chn ("%s: personne ne match ta demande :(" % (msg.sender))
|
msg.send_chn ("%s: personne ne match ta demande :(" % (msg.nick))
|
||||||
|
|
||||||
DELAYED = dict()
|
DELAYED = dict()
|
||||||
delayEvnt = threading.Event()
|
delayEvnt = threading.Event()
|
||||||
@ -108,7 +108,7 @@ def whereis_msg(msg):
|
|||||||
if len(msg.cmd) >= 2:
|
if len(msg.cmd) >= 2:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
name = msg.sender
|
name = msg.nick
|
||||||
else:
|
else:
|
||||||
names.append(name)
|
names.append(name)
|
||||||
pasla = whereis(msg, names)
|
pasla = whereis(msg, names)
|
||||||
@ -143,7 +143,7 @@ def whereis_msg(msg):
|
|||||||
else:
|
else:
|
||||||
for name in names:
|
for name in names:
|
||||||
msg.send_chn ("%s n'est pas connecté sur le PIE." % name)
|
msg.send_chn ("%s n'est pas connecté sur le PIE." % name)
|
||||||
|
|
||||||
|
|
||||||
def whereis(msg, names):
|
def whereis(msg, names):
|
||||||
pasla = list()
|
pasla = list()
|
||||||
@ -187,7 +187,7 @@ def parseanswer (msg):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def parseask (msg):
|
def parseask (msg):
|
||||||
if len(DELAYED) > 0 and msg.sender == msg.srv.partner:
|
if len(DELAYED) > 0 and msg.nick == msg.srv.partner:
|
||||||
treat = False
|
treat = False
|
||||||
for part in msg.content.split(';'):
|
for part in msg.content.split(';'):
|
||||||
if part is None:
|
if part is None:
|
||||||
|
@ -28,14 +28,14 @@ def parseanswer(msg):
|
|||||||
t = Tinyfier.Tinyfier(url, msg)
|
t = Tinyfier.Tinyfier(url, msg)
|
||||||
t.start()
|
t.start()
|
||||||
else:
|
else:
|
||||||
msg.send_chn("%s: je n'ai pas d'autre URL reduire" % msg.sender)
|
msg.send_chn("%s: je n'ai pas d'autre URL reduire" % msg.nick)
|
||||||
else:
|
else:
|
||||||
if len(msg.cmd) < 6:
|
if len(msg.cmd) < 6:
|
||||||
for url in msg.cmd[1:]:
|
for url in msg.cmd[1:]:
|
||||||
t = Tinyfier.Tinyfier(url, msg)
|
t = Tinyfier.Tinyfier(url, msg)
|
||||||
t.start()
|
t.start()
|
||||||
else:
|
else:
|
||||||
msg.send_chn("%s: je ne peux pas réduire autant d'URL d'un seul coup." % msg.sender)
|
msg.send_chn("%s: je ne peux pas réduire autant d'URL d'un seul coup." % msg.nick)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
10
nemuspeak.py
10
nemuspeak.py
@ -94,12 +94,12 @@ def speak(endstate):
|
|||||||
|
|
||||||
action = 0
|
action = 0
|
||||||
if msg.content.find("ACTION ") == 1:
|
if msg.content.find("ACTION ") == 1:
|
||||||
sentence += msg.sender + " "
|
sentence += msg.nick + " "
|
||||||
msg.content = msg.content.replace("ACTION ", "")
|
msg.content = msg.content.replace("ACTION ", "")
|
||||||
action = 1
|
action = 1
|
||||||
for (txt, mood) in SMILEY:
|
for (txt, mood) in SMILEY:
|
||||||
if msg.content.find(txt) >= 0:
|
if msg.content.find(txt) >= 0:
|
||||||
sentence += msg.sender + (" %s : "%mood)
|
sentence += msg.nick + (" %s : "%mood)
|
||||||
msg.content = msg.content.replace(txt, "")
|
msg.content = msg.content.replace(txt, "")
|
||||||
action = 1
|
action = 1
|
||||||
break
|
break
|
||||||
@ -109,7 +109,7 @@ def speak(endstate):
|
|||||||
msg.content = (" " + msg.content + " ").replace(bad, good)
|
msg.content = (" " + msg.content + " ").replace(bad, good)
|
||||||
|
|
||||||
if action == 0 and (force or msg.sender != lastmsg.sender):
|
if action == 0 and (force or msg.sender != lastmsg.sender):
|
||||||
sentence += msg.sender + " dit : "
|
sentence += msg.nick + " dit : "
|
||||||
|
|
||||||
if re.match(".*(https?://)?(www\\.)?ycc.fr/[a-z0-9A-Z]+.*", msg.content) is not None:
|
if re.match(".*(https?://)?(www\\.)?ycc.fr/[a-z0-9A-Z]+.*", msg.content) is not None:
|
||||||
msg.content = re.sub("(https?://)?(www\\.)?ycc.fr/[a-z0-9A-Z]+", " U.R.L Y.C.C ", msg.content)
|
msg.content = re.sub("(https?://)?(www\\.)?ycc.fr/[a-z0-9A-Z]+", " U.R.L Y.C.C ", msg.content)
|
||||||
@ -161,7 +161,7 @@ class Server:
|
|||||||
_thread.start_new_thread(self.connect, ())
|
_thread.start_new_thread(self.connect, ())
|
||||||
|
|
||||||
def authorize(self, msg):
|
def authorize(self, msg):
|
||||||
return msg.sender != OWNER and (msg.channel == OWNER or msg.channel in self.channels)
|
return msg.nick != OWNER and (msg.channel == OWNER or msg.channel in self.channels)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
global stopSpk, talkEC, g_queue
|
global stopSpk, talkEC, g_queue
|
||||||
@ -186,7 +186,7 @@ class Server:
|
|||||||
if msg.cmd == b"PING":
|
if msg.cmd == b"PING":
|
||||||
self.s.send(("PONG %s\r\n" % msg.content).encode ())
|
self.s.send(("PONG %s\r\n" % msg.content).encode ())
|
||||||
elif msg.cmd == b"PRIVMSG" and (self.authorize(msg) or msg.content[0] == '`'):
|
elif msg.cmd == b"PRIVMSG" and (self.authorize(msg) or msg.content[0] == '`'):
|
||||||
if msg.content[0] == '`' and msg.sender == OWNER:
|
if msg.content[0] == '`' and msg.nick == OWNER:
|
||||||
cmd = msg.content[1:].split(' ')
|
cmd = msg.content[1:].split(' ')
|
||||||
if cmd[0] == "speak":
|
if cmd[0] == "speak":
|
||||||
_thread.start_new_thread(speak, (0,))
|
_thread.start_new_thread(speak, (0,))
|
||||||
|
Loading…
Reference in New Issue
Block a user