Commit 45dcb7d7 authored by Jonathan Harker's avatar Jonathan Harker

For now, catch all the UTF-8 exceptions until I can fix it properly.

parent a187045c
......@@ -10,18 +10,22 @@ Useful bot for folks stuck behind censor walls at work
Logs a channel and collects URLs for later.
"""
import sys, string, random, time
from ircbot import SingleServerIRCBot, OutputManager
from irclib import nm_to_n, nm_to_h, irc_lower
import os
from datetime import datetime
from mechanize import Browser
import getopt
from sqlalchemy import MetaData, Table, Column, String, Text, Integer, DateTime, engine_from_config
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
try:
import sys, string, random, time
from ircbot import SingleServerIRCBot, OutputManager
from irclib import nm_to_n, nm_to_h, irc_lower
import os
from datetime import datetime
from mechanize import Browser
import getopt
from sqlalchemy import MetaData, Table, Column, String, Text, Integer, DateTime, engine_from_config
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
except ImportError:
print "Some modules could not be loaded: Lolbot relies on Mechanize and SQLAlchemy.\n"
sys.exit
# Exclamations - wrong input
exclamations = [
......@@ -37,7 +41,6 @@ exclamations = [
ponderings = [
"Hi, can I have a medium lamb roast, with just potatoes.",
"Can I slurp on your Big Cock?",
"Your Mum likes it two in the pink one in the stink.",
"Quentin Tarantino is so awesome I want to have his babies.",
"No it's a week night 8pm is past my bedtime.",
]
......@@ -193,6 +196,7 @@ class LolBot(SingleServerIRCBot):
return datetime.today().strftime("%Y-%m-%d %H:%M:%S")
def save_url(self, nickname, url):
try:
db = self.get_session()
if not db.query(Url).filter(Url.url == url).count():
theurl = Url(nickname, url)
......@@ -201,19 +205,25 @@ class LolBot(SingleServerIRCBot):
else:
try:
theurl = db.query(Url).filter(Url.url == url).one()
print theurl
return theurl.title
except MultipleResultsFound, ex:
print ex #wtf
except NoResultsFound, ex:
print ex #wtf
print theurl
return theurl.title
except Exception, ex:
print "Exception caught saving URL: %s" % ex
return ""
def log_event(self, nick, text):
try:
entry = Log(nick, text)
db = self.get_session()
db.add(entry)
db.commit()
print entry
except Exception, ex:
print "Exception caught logging event: %s" % ex
def on_nicknameinuse(self, connection, event):
self.nickname = connection.get_nickname() + "_"
......@@ -280,6 +290,7 @@ class LolBot(SingleServerIRCBot):
else:
target = from_private.strip()
try:
if cmd == 'help':
self.reply(self.helptext, target)
......@@ -303,6 +314,10 @@ class LolBot(SingleServerIRCBot):
else:
self.reply(self.exclaim(), target)
except Exception, ex:
print "Exception caught processing command: %s" % ex
print " command was '%s' from %s" % (cmd, target)
def usage():
print """Run a lolbot.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment