Updated doJoin to use utils.nItems and made it doPrivmsg instead.

This commit is contained in:
Jeremy Fincher 2003-09-03 17:43:06 +00:00
parent bb91ade49e
commit 4200b4a4a7

View File

@ -139,7 +139,7 @@ class Notes(callbacks.Privmsg):
self.db.close() self.db.close()
del self.db del self.db
def doJoin(self, irc, msg): def doPrivmsg(self, irc, msg):
try: try:
name = ircdb.users.getUserName(msg.prefix) name = ircdb.users.getUserName(msg.prefix)
except KeyError: except KeyError:
@ -157,18 +157,15 @@ class Notes(callbacks.Privmsg):
notes.to_id=users.id AND notes.to_id=users.id AND
read=0""", name) read=0""", name)
unread = int(cursor.fetchone()[0]) unread = int(cursor.fetchone()[0])
s = 'You have %s unread %s; ' \ s = 'You have %s; ' \
'%s that I haven\'t told you about before now..' % \ '%s that I haven\'t told you about before now..' % \
(unread, utils.pluralize(unread, 'note'), unnotified) (utils.nItems(unread, 'note', 'unread'), unnotified)
irc.queueMsg(ircmsgs.privmsg(msg.nick, s)) irc.queueMsg(ircmsgs.privmsg(msg.nick, s))
cursor.execute("""UPDATE notes cursor.execute("""UPDATE notes
SET notified=1 SET notified=1
WHERE notes.to_id=(SELECT id WHERE notes.to_id=(SELECT id
FROM users FROM users
WHERE name=%s)""", name) WHERE name=%s)""", name)
def doPrivmsg(self, irc, msg):
self.doJoin(irc, msg)
callbacks.Privmsg.doPrivmsg(self, irc, msg) callbacks.Privmsg.doPrivmsg(self, irc, msg)
def sendnote(self, irc, msg, args): def sendnote(self, irc, msg, args):