mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +01:00
Changed implementation of notes command.
This commit is contained in:
parent
ab1d8cecd6
commit
250cf8a95a
@ -196,13 +196,12 @@ class Notes(callbacks.Privmsg):
|
||||
self.cursor.execute("""SELECT id, from_id, public, read FROM notes
|
||||
WHERE to_id=%s
|
||||
AND read=0""", senderID)
|
||||
count = cursor.rowcount
|
||||
notes = self.cursor.fetchall()
|
||||
self.cursor.execute("""SELECT count(*) FROM notes
|
||||
WHERE to_id=%s
|
||||
AND read=0""", senderID)
|
||||
count = int(self.cursor.fetchone()[0])
|
||||
#debug.printf("count: %s" % count)
|
||||
L = []
|
||||
if count == 0:
|
||||
irc.reply(msg, 'You have no unread notes.')
|
||||
else:
|
||||
for (id, from_id, public, read) in notes:
|
||||
if not int(read):
|
||||
sender = self.getUserName(from_id)
|
||||
@ -210,14 +209,9 @@ class Notes(callbacks.Privmsg):
|
||||
L.append(r'#%s from %s' % (id, sender))
|
||||
else:
|
||||
L.append(r'#%s (private)' % id)
|
||||
if count > 5:
|
||||
L = string.join(L[:5], ', ')
|
||||
reply = "you have %s unread notes, 5 shown: %s" % (count, L)
|
||||
else:
|
||||
L = string.join(L, ', ')
|
||||
reply = "you have %s unread notes: %s" % (count, L)
|
||||
#debug.printf(L)
|
||||
irc.reply(msg, reply)
|
||||
while reduce(operator.add, L) + 2*len(L) > 400:
|
||||
L.pop()
|
||||
irc.reply(msg, ', '.join(L))
|
||||
|
||||
|
||||
Class = Notes
|
||||
|
Loading…
Reference in New Issue
Block a user