]> jfr.im git - irc/rizon/acid.git/commitdiff
try/except unicode decode errors because python
authorAdam <redacted>
Wed, 17 Sep 2014 05:09:59 +0000 (01:09 -0400)
committerAdam <redacted>
Wed, 17 Sep 2014 05:09:59 +0000 (01:09 -0400)
pyva/pyva/src/main/python/ctcp/ctcp.py
pyva/pyva/src/main/python/trivia/trivia_engine.py

index 63fbd29f1de1c40b823c7bc7d798e6a5c49f3957..98e5a2bfdc84e97722f0d66a17c429d61383df16 100644 (file)
@@ -110,14 +110,17 @@ class ctcp(AcidPlugin):
                        return # Can this throw?
 
                #ctcp website reply
-               if reply.lower().startswith(u"website"):
-                       reply = reply[8:]
-                       try:
-                               self.dbp.execute(u"INSERT INTO ctcp_website (reply, found) VALUES(%s, 1) ON DUPLICATE KEY UPDATE found=found+1;", (reply,))
-                       except Exception, err:
-                               self.log.exception(u"Error updating ctcp_website: %s (%s)" % (reply, err))
-                       user['website'] = reply
-                       return
+               try:
+                       if reply.lower().startswith(u"website"):
+                               reply = reply[8:]
+                               try:
+                                       self.dbp.execute(u"INSERT INTO ctcp_website (reply, found) VALUES(%s, 1) ON DUPLICATE KEY UPDATE found=found+1;", (reply,))
+                               except Exception, err:
+                                       self.log.exception(u"Error updating ctcp_website: %s (%s)" % (reply, err))
+                               user['website'] = reply
+                               return
+               except:
+                       return # XXX
 
                #ctcp version reply
                if not reply.lower().startswith(u"version"): return
index 901ddba4137f539e25979ca44f2560a242049424..47e2c238bd72d78f8745d8e32e3e7edb31263cb1 100644 (file)
@@ -161,9 +161,12 @@ class Trivia(object):
 
                found = False
                for a in self.answer:
-                       if a.lower() in answer.lower():
-                               found = True
-                               break
+                       try:
+                               if a.lower() in answer.lower():
+                                       found = True
+                                       break
+                       except:
+                               pass # XXX unicode
 
                if not found:
                        return