mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
Made zipcode handle zipcodefor stuff.
This commit is contained in:
parent
9db6ace58b
commit
cb6f1a1432
@ -117,6 +117,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
self.db = makeDb(dbFilename)
|
self.db = makeDb(dbFilename)
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
|
self.db.commit()
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -425,6 +426,12 @@ class FunDB(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
zipcode = int(privmsgs.getArgs(args))
|
zipcode = int(privmsgs.getArgs(args))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
# Must not be an integer. Try zipcodefor.
|
||||||
|
try:
|
||||||
|
self.zipcodefor(irc, msg, args)
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
irc.error(msg, 'Invalid zipcode.')
|
irc.error(msg, 'Invalid zipcode.')
|
||||||
return
|
return
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
@ -444,6 +451,8 @@ class FunDB(callbacks.Privmsg):
|
|||||||
Returns the zipcode for a <city> in <state>.
|
Returns the zipcode for a <city> in <state>.
|
||||||
"""
|
"""
|
||||||
(city, state) = privmsgs.getArgs(args, needed=2)
|
(city, state) = privmsgs.getArgs(args, needed=2)
|
||||||
|
state = args.pop()
|
||||||
|
city = ' '.join(args)
|
||||||
if '%' in msg.args[1]:
|
if '%' in msg.args[1]:
|
||||||
irc.error(msg, '% wildcard is not allowed. Use _ instead.')
|
irc.error(msg, '% wildcard is not allowed. Use _ instead.')
|
||||||
return
|
return
|
||||||
@ -454,7 +463,8 @@ class FunDB(callbacks.Privmsg):
|
|||||||
WHERE city LIKE %s AND
|
WHERE city LIKE %s AND
|
||||||
state LIKE %s""", city, state)
|
state LIKE %s""", city, state)
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
irc.reply(msg, 'I have no zipcode for that city/state.')
|
irc.reply(msg, 'I have no zipcode for %r, %r.' % \
|
||||||
|
(city, state))
|
||||||
elif cursor.rowcount == 1:
|
elif cursor.rowcount == 1:
|
||||||
irc.reply(msg, str(cursor.fetchone()[0]))
|
irc.reply(msg, str(cursor.fetchone()[0]))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user