config_irc_password="I'mAHungMan"
config_irc_pseudo="Hung"
-config_chanlist=["#flood"]
-config_stay_channels=["#flood"]
+config_chanlist=["#bot","#flood"]
+config_stay_channels=["#bot","#flood"]
+config_play_channels=["#flood"]
config_quiet_channels=[]
config_logfile_template="hung.%s.log"
def get_config_logfile(serveur):
config_ops=[]
config_report_bugs_to=["[20-100]"]
+config_dico_file="dico"
+
def log(serveur,channel,auteur=None,message=None):
f=open(get_config_logfile(serveur),"a")
if auteur==message==None:
self.chanlist=config_chanlist
self.stay_channels=config_stay_channels
self.play_channels=config_play_channels
+ self.play_status={}
self.quiet_channels=config_quiet_channels
log("priv",auteur," ".join(message)+"[failed]")
else:
self.play_channels.append(message[1])
- self.play_status[message[1]]=None
+ self.play_status[message[1]]=[None]
serv.privmsg(auteur,"Play channels : "+" ".join(self.play_channels))
log("priv",auteur," ".join(message)+"[successful]")
else:
else:
notunderstood=True
+ elif cmd in ["states","status"]:
+ if auteur in self.overops:
+ for k in self.play_status.keys():
+ serv.privmsg(auteur,"%s : %s"%(k,"; ".join([str(i) for i in self.play_status[k]])))
elif cmd=="die":
if auteur in self.overops:
log(self.serveur,"priv",auteur," ".join(message)+"[successful]")
notunderstood=True
if notunderstood:
serv.privmsg(auteur,"Je n'ai pas compris. Essaye HELP…")
-
+
+ def affiche_mot(self, serv, canal, begin="Mot courant"):
+ if self.play_status.has_key(canal):
+ mot = self.play_status[canal]
+ obfuskated=" ".join([lettre[0] if lettre[1] else "_" for lettre in mot])
+ serv.privmsg(canal,"%s : %s"%(begin,obfuskated))
+
+ def start_partie(self, serv, canal):
+ dico=[mot.strip() for mot in open(config_dico_file).readlines()]
+ mot = random.choice(dico)
+ # ' et - sont considérés comme déjà devinés
+ mot = [(lettre,lettre in "'-") for lettre in list(mot)]
+ self.play_status[canal]=mot
+ self.affiche_mot(serv, canal, begin="Devinez")
+
def on_pubmsg(self, serv, ev):
auteur = irclib.nm_to_n(ev.source())
canal = ev.target()
else:
serv.privmsg(canal,"%s: Non, je reste !"%(auteur))
log(self.serveur,canal,auteur,message+"[failed]")
-
+ elif cmd in ["play","jeu","encore","again","partie","pendu","game","mot"]:
+ if not canal in self.quiet_channels and canal in self.play_channels:
+ if self.play_status.has_key(canal):
+ if self.play_status[canal]==[None]:
+ self.start_partie(serv, canal)
+ else:
+ self.affiche_mot(serv, canal, begin="%s: Rappel"%(auteur))
+ else:
+ self.play_status[canal]=[None]
+ self.start_partie(serv, canal)
+ elif not canal in self.play_channels:
+ serv.privmsg(canal,"%s: pas ici…"%(auteur))
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))
else: