mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
Added a 'next' command.
This commit is contained in:
parent
d5c279e604
commit
7cf0728633
@ -151,8 +151,7 @@ class Note(callbacks.Plugin):
|
|||||||
ids = self.db.getUnnotifiedIds(to)
|
ids = self.db.getUnnotifiedIds(to)
|
||||||
if len(ids) <= self.registryValue('notify.autoSend'):
|
if len(ids) <= self.registryValue('notify.autoSend'):
|
||||||
for id in ids:
|
for id in ids:
|
||||||
s = '#%s: %s' % (id, self._formatNote(self.db.get(id), to))
|
irc.reply(self._formatNote(self.db.get(id), to), private=True)
|
||||||
irc.reply(s, private=True)
|
|
||||||
self.db.setRead(id)
|
self.db.setRead(id)
|
||||||
return
|
return
|
||||||
unnotifiedIds = ['#%s' % nid for nid in ids]
|
unnotifiedIds = ['#%s' % nid for nid in ids]
|
||||||
@ -244,13 +243,13 @@ class Note(callbacks.Plugin):
|
|||||||
elapsed = utils.timeElapsed(time.time() - note.at)
|
elapsed = utils.timeElapsed(time.time() - note.at)
|
||||||
if note.to == to:
|
if note.to == to:
|
||||||
author = plugins.getUserName(note.frm)
|
author = plugins.getUserName(note.frm)
|
||||||
return format('%s (Sent by %s %s ago)',
|
return format('#%i: %s (Sent by %s %s ago)',
|
||||||
note.text, author, elapsed)
|
note.id, note.text, author, elapsed)
|
||||||
else:
|
else:
|
||||||
assert note.frm == to, 'Odd, userid isn\'t frm either.'
|
assert note.frm == to, 'Odd, userid isn\'t frm either.'
|
||||||
recipient = plugins.getUserName(note.to)
|
recipient = plugins.getUserName(note.to)
|
||||||
return format('%s (Sent to %s %s ago)',
|
return format('#%i: %s (Sent to %s %s ago)',
|
||||||
note.text, recipient, elapsed)
|
note.id, note.text, recipient, elapsed)
|
||||||
|
|
||||||
def note(self, irc, msg, args, user, id):
|
def note(self, irc, msg, args, user, id):
|
||||||
"""<id>
|
"""<id>
|
||||||
@ -363,6 +362,30 @@ class Note(callbacks.Plugin):
|
|||||||
'from': 'otherUser',
|
'from': 'otherUser',
|
||||||
'to': 'otherUser'})])
|
'to': 'otherUser'})])
|
||||||
|
|
||||||
|
def next(self, irc, msg, args, user):
|
||||||
|
"""takes no arguments
|
||||||
|
|
||||||
|
Retrieves your next unread note, if any.
|
||||||
|
"""
|
||||||
|
notes = self.db.getUnreadIds(user.id)
|
||||||
|
if not notes:
|
||||||
|
irc.reply('You have no unread notes.')
|
||||||
|
else:
|
||||||
|
found = False
|
||||||
|
for id in notes:
|
||||||
|
try:
|
||||||
|
note = self.db.get(id)
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if not found:
|
||||||
|
irc.reply('You have no unread notes.')
|
||||||
|
else:
|
||||||
|
irc.reply(self._formatNote(note, user.id), private=(not note.public))
|
||||||
|
self.db.setRead(note.id)
|
||||||
|
next = wrap(next, ['user'])
|
||||||
|
|
||||||
def _condense(self, notes):
|
def _condense(self, notes):
|
||||||
temp = {}
|
temp = {}
|
||||||
for note in notes:
|
for note in notes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user