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,28 +196,22 @@ class Notes(callbacks.Privmsg):
|
|||||||
self.cursor.execute("""SELECT id, from_id, public, read FROM notes
|
self.cursor.execute("""SELECT id, from_id, public, read FROM notes
|
||||||
WHERE to_id=%s
|
WHERE to_id=%s
|
||||||
AND read=0""", senderID)
|
AND read=0""", senderID)
|
||||||
|
count = cursor.rowcount
|
||||||
notes = self.cursor.fetchall()
|
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 = []
|
L = []
|
||||||
for (id, from_id, public, read) in notes:
|
if count == 0:
|
||||||
if not int(read):
|
irc.reply(msg, 'You have no unread notes.')
|
||||||
sender = self.getUserName(from_id)
|
|
||||||
if int(public):
|
|
||||||
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:
|
else:
|
||||||
L = string.join(L, ', ')
|
for (id, from_id, public, read) in notes:
|
||||||
reply = "you have %s unread notes: %s" % (count, L)
|
if not int(read):
|
||||||
#debug.printf(L)
|
sender = self.getUserName(from_id)
|
||||||
irc.reply(msg, reply)
|
if int(public):
|
||||||
|
L.append(r'#%s from %s' % (id, sender))
|
||||||
|
else:
|
||||||
|
L.append(r'#%s (private)' % id)
|
||||||
|
while reduce(operator.add, L) + 2*len(L) > 400:
|
||||||
|
L.pop()
|
||||||
|
irc.reply(msg, ', '.join(L))
|
||||||
|
|
||||||
|
|
||||||
Class = Notes
|
Class = Notes
|
||||||
|
Loading…
Reference in New Issue
Block a user