chain = "%s %s" % (time.strftime("%F %T"), channel)
else:
chain = "%s [%s:%s] %s" % (time.strftime("%F %T"), channel, auteur, message)
- f.write(chain+"\n")
+ f.write(chain + "\n")
if config.debug_stdout:
print chain
f.close()
chain = unicode(chain, "utf8")
else:
chain = unicode(chain, "utf8").lower()
- allmatches = "("+"|".join(matches)+")"
- reg = (avant+allmatches+apres).lower()
+ allmatches = "(" + "|".join(matches) + ")"
+ reg = (avant + allmatches + apres).lower()
o = re.match(reg, chain)
return o
return is_something(chain, config.insultes, avant=".*(?:^| |')")
def is_not_insult(chain):
chain = unicode(chain, "utf8")
- insult_regexp = u"("+u"|".join(config.insultes)+u")"
+ insult_regexp = u"(" + u"|".join(config.insultes) + u")"
middle_regexp = u"(une? (?:(?:putain|enfoiré) d(?:e |'))*|)(?:| super )(?: (?:gros|petit|grand|énorme) |)"
reg = ".*pas %s%s.*" % (middle_regexp, insult_regexp)
if re.match(reg, chain):
class Skeleton(ircbot.SingleServerIRCBot):
def __init__(self, serveur, debug=False):
- temporary_pseudo = config.irc_pseudo+str(random.randrange(10000, 100000))
+ temporary_pseudo = config.irc_pseudo + str(random.randrange(10000, 100000))
ircbot.SingleServerIRCBot.__init__(self, [(serveur, 6667)],
temporary_pseudo, "Ceci est l'ircname du bot", 10)
self.debug = debug
self.serveur = serveur
self.overops = config.overops
- self.ops = self.overops+config.ops
+ self.ops = self.overops + config.ops
self.chanlist = config.chanlist
self.stay_channels = config.stay_channels
self.quiet_channels = config.quiet_channels
pseudo = self.nick
size = len(pseudo)
if message[:size] == pseudo and len(message)>size and message[size] == ":":
- return (True, message[size+1:].lstrip(" "))
+ return (True, message[size + 1:].lstrip(" "))
else:
return (False, message)
helpmsg = helpmsgs[0]
if op and helpmsgs[1]:
if helpmsg:
- helpmsg += "\n"+helpmsgs[1]
+ helpmsg += "\n" + helpmsgs[1]
else:
helpmsg = helpmsgs[1]
if overop and helpmsgs[2]:
if helpmsg:
- helpmsg += "\n"+helpmsgs[2]
+ helpmsg += "\n" + helpmsgs[2]
else:
helpmsg = helpmsgs[2]
for ligne in helpmsg.split("\n"):
else:
serv.join(message[1])
self.chanlist.append(message[1])
- serv.privmsg(auteur, "Channels : "+" ".join(self.chanlist))
+ serv.privmsg(auteur, "Channels : " + " ".join(self.chanlist))
log(self.serveur, "priv", auteur, " ".join(message))
else:
- serv.privmsg(auteur, "Channels : "+" ".join(self.chanlist))
+ serv.privmsg(auteur, "Channels : " + " ".join(self.chanlist))
else:
notunderstood = True
elif cmd == "leave":
if not (message[1] in self.stay_channels) or auteur in self.overops:
self.quitter(message[1], " ".join(message[2:]))
self.chanlist.remove(message[1])
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
else:
serv.privmsg(auteur, "Non, je reste !")
- log(self.serveur, "priv", auteur, " ".join(message)+"[failed]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[failed]")
else:
serv.privmsg(auteur, "Je ne suis pas sur %s" % (message[1]))
else:
if auteur in self.overops:
if len(message)>1:
if message[1] in self.stay_channels:
- log(self.serveur, "priv", auteur, " ".join(message)+"[failed]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[failed]")
serv.privmsg(auteur, "Je stay déjà sur %s." % (message[1]))
else:
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
self.stay_channels.append(message[1])
- serv.privmsg(auteur, "Stay channels : "+" ".join(self.stay_channels))
+ serv.privmsg(auteur, "Stay channels : " + " ".join(self.stay_channels))
else:
- serv.privmsg(auteur, "Stay channels : "+" ".join(self.stay_channels))
+ serv.privmsg(auteur, "Stay channels : " + " ".join(self.stay_channels))
else:
notunderstood = True
elif cmd == "nostay":
if auteur in self.overops:
if len(message)>1:
if message[1] in self.stay_channels:
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
self.stay_channels.remove(message[1])
- serv.privmsg(auteur, "Stay channels : "+" ".join(self.stay_channels))
+ serv.privmsg(auteur, "Stay channels : " + " ".join(self.stay_channels))
else:
- log(self.serveur, "priv", auteur, " ".join(message)+"[failed]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[failed]")
serv.privmsg(auteur, "Je ne stay pas sur %s." % (message[1]))
else:
notunderstood = True
elif cmd == "die":
if auteur in self.overops:
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
self.mourir()
else:
notunderstood = True
if len(message)>1:
if message[1] in self.quiet_channels:
serv.privmsg(auteur, "Je me la ferme déjà sur %s" % (message[1]))
- log(self.serveur, "priv", auteur, " ".join(message)+"[failed]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[failed]")
else:
self.quiet_channels.append(message[1])
- serv.privmsg(auteur, "Quiet channels : "+" ".join(self.quiet_channels))
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ serv.privmsg(auteur, "Quiet channels : " + " ".join(self.quiet_channels))
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
else:
- serv.privmsg(auteur, "Quiet channels : "+" ".join(self.quiet_channels))
+ serv.privmsg(auteur, "Quiet channels : " + " ".join(self.quiet_channels))
else:
notunderstood = True
elif cmd == "noquiet":
if len(message)>1:
if message[1] in self.quiet_channels:
self.quiet_channels.remove(message[1])
- serv.privmsg(auteur, "Quiet channels : "+" ".join(self.quiet_channels))
- log(self.serveur, "priv", auteur, " ".join(message)+"[successful]")
+ serv.privmsg(auteur, "Quiet channels : " + " ".join(self.quiet_channels))
+ log(self.serveur, "priv", auteur, " ".join(message) + "[successful]")
else:
serv.privmsg(auteur, "Je ne me la ferme pas sur %s." % (message[1]))
- log(self.serveur, "priv", auteur, " ".join(message)+"[failed]")
+ log(self.serveur, "priv", auteur, " ".join(message) + "[failed]")
else:
notunderstood = True
elif cmd == "say":
args = ""
if cmd in ["meurs", "die", "crève"]:
if auteur in self.overops:
- log(self.serveur, canal, auteur, message+"[successful]")
+ log(self.serveur, canal, auteur, message + "[successful]")
self.mourir()
else:
serv.privmsg(canal, ("%s: %s" % (auteur, random.choice(config.quit_fail_messages))).encode("utf8"))
- log(self.serveur, canal, auteur, message+"[failed]")
+ log(self.serveur, canal, auteur, message + "[failed]")
elif cmd in ["part", "leave", "dégage", "va-t-en", "tut'tiresailleurs, c'estmesgalets"]:
if auteur in self.ops and (not (canal in self.stay_channels)
or auteur in self.overops):
self.quitter(canal)
- log(self.serveur, canal, auteur, message+"[successful]")
+ log(self.serveur, canal, auteur, message + "[successful]")
if canal in self.chanlist:
self.chanlist.remove(canal)
else:
serv.privmsg(canal, ("%s: %s" % (auteur, random.choice(config.leave_fail_messages))).encode("utf8"))
- log(self.serveur, canal, auteur, message+"[failed]")
+ log(self.serveur, canal, auteur, message + "[failed]")
elif cmd in ["deviens", "pseudo"]:
if auteur in self.ops:
become = args
serv.nick(become)
- log(self.serveur, canal, auteur, message+"[successful]")
+ log(self.serveur, canal, auteur, message + "[successful]")
if cmd in ["meur", "meurt", "meurre", "meurres"] and not canal in self.quiet_channels:
serv.privmsg(canal, '%s: Mourir, impératif, 2ème personne du singulier : "meurs" (de rien)' % (auteur))
if is_tesla(message) and not canal in self.quiet_channels:
l1, l2 = config.tesla_answers, config.tesla_actions
n1, n2 = len(l1), len(l2)
- i = random.randrange(n1+n2)
+ i = random.randrange(n1 + n2)
if i >= n1:
- serv.action(canal, l2[i-n1].encode("utf8"))
+ serv.action(canal, l2[i - n1].encode("utf8"))
else:
serv.privmsg(canal, "%s: %s" % (auteur, l1[i].encode("utf8")))
if is_tamere(message) and not canal in self.quiet_channels:
else:
if not canal in self.quiet_channels:
mypseudo = self.nick
- if re.match((u"^("+u"|".join(config.bonjour_triggers)
- +ur")( {}| all| tout le monde| (à )?tous)(\.| ?!)?$"
+ if re.match((u"^(" + u"|".join(config.bonjour_triggers)
+ + ur")( {}| all| tout le monde| (à )?tous)(\.| ?!)?$"
).format(mypseudo).lower(), message.decode("utf8").strip().lower()):
answer = random.choice(config.bonjour_answers)
serv.privmsg(canal, answer.format(auteur).encode("utf8"))
if is_bad_action_trigger(action, mypseudo) and not channel in self.quiet_channels:
l1, l2 = config.bad_action_answers, config.bad_action_actions
n1, n2 = len(l1), len(l2)
- i = random.randrange(n1+n2)
+ i = random.randrange(n1 + n2)
if i >= n1:
- serv.action(channel, l2[i-n1].format(auteur).encode("utf8"))
+ serv.action(channel, l2[i - n1].format(auteur).encode("utf8"))
else:
serv.privmsg(channel, l1[i].format(auteur).format(auteur).encode("utf8"))
if is_good_action_trigger(action, mypseudo) and not channel in self.quiet_channels:
l1, l2 = config.good_action_answers, config.good_action_actions
n1, n2 = len(l1), len(l2)
- i = random.randrange(n1+n2)
+ i = random.randrange(n1 + n2)
if i >= n1:
- serv.action(channel, l2[i-n1].format(auteur).format(auteur).encode("utf8"))
+ serv.action(channel, l2[i - n1].format(auteur).format(auteur).encode("utf8"))
else:
serv.privmsg(channel, l1[i].format(auteur).format(auteur).encode("utf8"))
serv.join(channel)
l1, l2 = config.kick_answers, config.kick_actions
n1, n2 = len(l1), len(l2)
- i = random.randrange(n1+n2)
+ i = random.randrange(n1 + n2)
if i >= n1:
- serv.action(channel, l2[i-n1].format(auteur).encode("utf8"))
+ serv.action(channel, l2[i - n1].format(auteur).encode("utf8"))
else:
serv.privmsg(channel, l1[i].format(auteur).encode("utf8"))