Some small refactorings, fixed a problem in unsend.

This commit is contained in:
Jeremy Fincher 2005-03-09 10:43:01 +00:00
parent 0e68a44513
commit 1f49fc1e3e
1 changed files with 7 additions and 5 deletions

View File

@ -203,7 +203,7 @@ class Note(callbacks.Plugin):
"""
try:
note = self.db.get(id)
except KeyError:
except dbi.NoRecordError:
irc.error('That\'s not a note in my database.', Raise=True)
if note.to != user.id:
irc.error('You may only reply to notes '
@ -226,7 +226,10 @@ class Note(callbacks.Plugin):
Unsends the note with the id given. You must be the
author of the note, and it must be unread.
"""
note = self.db.get(id)
try:
note = self.db.get(id)
except dbi.NoRecordError:
irc.errorInvalid('note id')
if note.frm == user.id:
if not note.read:
self.db.unsend(id)
@ -257,9 +260,8 @@ class Note(callbacks.Plugin):
"""
try:
note = self.db.get(id)
except KeyError:
irc.error('That\'s not a valid note id.')
return
except dbi.NoRecordError:
irc.errorInvalid('note id')
if user.id != note.frm and user.id != note.to:
s = 'You may only retrieve notes you\'ve sent or received.'
irc.error(s)