Removed some extraneous escaping of quotes and switched _tables from a list to a set.

This commit is contained in:
James Vega 2003-08-22 06:08:55 +00:00
parent b785cc220f
commit 9b3faa1982

View File

@ -35,6 +35,7 @@ Provides fun commands that require a database to operate.
from baseplugin import * from baseplugin import *
import sets
import string import string
import random import random
import os.path import os.path
@ -114,6 +115,11 @@ class FunDB(callbacks.Privmsg):
""" """
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
self._tables = sets.Set()
self._tables.add('lart')
self._tables.add('insult')
self._tables.add('excuse')
self._tables.add('praise')
self.db = makeDb(dbFilename) self.db = makeDb(dbFilename)
def die(self): def die(self):
@ -231,7 +237,6 @@ class FunDB(callbacks.Privmsg):
else: else:
irc.reply(msg, cursor.fetchone()[0]) irc.reply(msg, cursor.fetchone()[0])
_tables = ['lart','excuse','insult','praise']
def adddb(self, irc, msg, args): def adddb(self, irc, msg, args):
"""<lart|excuse|insult|praise> <text> """<lart|excuse|insult|praise> <text>
@ -245,7 +250,7 @@ class FunDB(callbacks.Privmsg):
'somewhere.') 'somewhere.')
return return
elif table not in self._tables: elif table not in self._tables:
irc.error(msg, '\"%s\" is an invalid choice. Must be one of: '\ irc.error(msg, '"%s" is an invalid choice. Must be one of: '\
'lart, excuse, insult, praise.' % table) 'lart, excuse, insult, praise.' % table)
return return
cursor = self.db.cursor() cursor = self.db.cursor()
@ -267,7 +272,7 @@ class FunDB(callbacks.Privmsg):
irc.error(msg, 'You must give a numeric id.') irc.error(msg, 'You must give a numeric id.')
return return
if table not in self._tables: if table not in self._tables:
irc.error(msg, '\"%s\" is an invalid choice. Must be one of: '\ irc.error(msg, '"%s" is an invalid choice. Must be one of: '\
'lart, excuse, insult, praise.' % table) 'lart, excuse, insult, praise.' % table)
return return
cursor = self.db.cursor() cursor = self.db.cursor()
@ -284,7 +289,7 @@ class FunDB(callbacks.Privmsg):
table = privmsgs.getArgs(args) table = privmsgs.getArgs(args)
table = str.lower(table) table = str.lower(table)
if table not in self._tables: if table not in self._tables:
irc.error(msg, '\"%s\" is an invalid choice. Must be one of: '\ irc.error(msg, '"%s" is an invalid choice. Must be one of: '\
'lart, excuse, insult, praise.' % table) 'lart, excuse, insult, praise.' % table)
return return
cursor = self.db.cursor() cursor = self.db.cursor()
@ -306,7 +311,7 @@ class FunDB(callbacks.Privmsg):
irc.error(msg, 'The id must be an integer.') irc.error(msg, 'The id must be an integer.')
return return
if table not in self._tables: if table not in self._tables:
irc.error(msg, '\"%s\" is an invalid choice. Must be one of: '\ irc.error(msg, '"%s" is an invalid choice. Must be one of: '\
'lart, excuse, insult, praise.' % table) 'lart, excuse, insult, praise.' % table)
return return
cursor = self.db.cursor() cursor = self.db.cursor()