]> gitweb.pimeys.fr Git - bots/basile.git/blobdiff - basile.py
Précaution encodage foireux dans on_action
[bots/basile.git] / basile.py
index c9058c017feefbef8f3fbd98e989b7ea4f6016ae..e7ed6cae2bcedde6de97c3a0f849c1d1314550e7 100755 (executable)
--- a/basile.py
+++ b/basile.py
@@ -442,7 +442,7 @@ class Basile(ircbot.SingleServerIRCBot):
  LOST       Perdre sur un chan
  SOLDE <pseudo>  Donner le solde de quelqu'un"""
             helpmsg_overops="""
- SAY        Fais envoyer un message sur un chan ou à une personne
+ SAY        Fait envoyer un message sur un chan ou à une personne
  STAY       Ignorera les prochains LEAVE pour un chan
  NOSTAY     Opposé de STAY
  DIE        Mourir"""
@@ -825,13 +825,20 @@ class Basile(ircbot.SingleServerIRCBot):
         action = ev.arguments()[0]
         auteur = irclib.nm_to_n(ev.source())
         channel = ev.target()
+        try:
+            test=bot_unicode(message)
+        except UnicodeBotError:
+            serv.privmsg(channel,
+              "%s : Euh, tu fais de la merde avec ton encodage là, j'ai failli crasher…"%(auteur))
+            return
         mypseudo=serv.get_nickname()
+        
         if is_action_trigger(action,mypseudo):
             l1,l2=config_action_answers,config_action_actions
             n1,n2=len(l1),len(l2)
             i=random.randrange(n1+n2)
             if i>=n1:
-                serv.action(channel,l2[i-n1])
+                serv.action(channel,l2[i-n1].encode("utf8"))
             else:
                 serv.privmsg(channel,"%s: %s"%(auteur,l1[i].encode("utf8")))