Changed the name of Notes to Note and changed some command names in Note.

This commit is contained in:
Jeremy Fincher 2003-11-11 12:59:27 +00:00
parent 0ca15118e7
commit 86e2110010
2 changed files with 21 additions and 17 deletions

View File

@ -52,7 +52,7 @@ import callbacks
dbfilename = os.path.join(conf.dataDir, 'Notes.db') dbfilename = os.path.join(conf.dataDir, 'Notes.db')
class Notes(callbacks.Privmsg): class Note(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
self.makeDB(dbfilename) self.makeDB(dbfilename)
@ -109,7 +109,7 @@ class Notes(callbacks.Privmsg):
WHERE notes.to_id=%s""", id) WHERE notes.to_id=%s""", id)
self.db.commit() self.db.commit()
def sendnote(self, irc, msg, args): def send(self, irc, msg, args):
"""<recipient> <text> """<recipient> <text>
Sends a new note to the user specified. Sends a new note to the user specified.
@ -146,7 +146,7 @@ class Notes(callbacks.Privmsg):
id = cursor.fetchone()[0] id = cursor.fetchone()[0]
irc.reply(msg, 'Note #%s sent to %s.' % (id, name)) irc.reply(msg, 'Note #%s sent to %s.' % (id, name))
def note(self, irc, msg, args): def get(self, irc, msg, args):
"""<note id> """<note id>
Retrieves a single note by its unique note id. Retrieves a single note by its unique note id.
@ -186,11 +186,16 @@ class Notes(callbacks.Privmsg):
else: else:
return '#%s (private)' % id return '#%s (private)' % id
def notes(self, irc, msg, args): def list(self, irc, msg, args):
"""takes no arguments """[--old]
Retrieves the ids of all your unread notes. Retrieves the ids of all your unread notes. If --old is given, list
read notes.
""" """
if '--old' in args:
while '--old' in args:
args.remove('--old')
self._oldnotes(irc, msg, args)
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
except KeyError: except KeyError:
@ -208,7 +213,7 @@ class Notes(callbacks.Privmsg):
L = [self._formatNoteData(msg, *t) for t in cursor.fetchall()] L = [self._formatNoteData(msg, *t) for t in cursor.fetchall()]
irc.reply(msg, utils.commaAndify(L)) irc.reply(msg, utils.commaAndify(L))
def oldnotes(self, irc, msg, args): def _oldnotes(self, irc, msg, args):
"""takes no arguments """takes no arguments
Returns a list of your most recent old notes. Returns a list of your most recent old notes.
@ -230,7 +235,6 @@ class Notes(callbacks.Privmsg):
irc.reply(msg, utils.commaAndify(ids)) irc.reply(msg, utils.commaAndify(ids))
Class = Note
Class = Notes
# vim: shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim: shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -40,8 +40,8 @@ except ImportError:
sqlite = None sqlite = None
if sqlite is not None: if sqlite is not None:
class NotesTestCase(PluginTestCase, PluginDocumentation): class NoteTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Notes', 'Misc', 'User') plugins = ('Note', 'Misc', 'User')
def testSendnote(self): def testSendnote(self):
#print repr(ircdb.users.getUser(self.prefix)) #print repr(ircdb.users.getUser(self.prefix))
self.prefix = 'foo!bar@baz' self.prefix = 'foo!bar@baz'
@ -49,19 +49,19 @@ if sqlite is not None:
(id, u) = ircdb.users.newUser() (id, u) = ircdb.users.newUser()
u.name = 'inkedmn' u.name = 'inkedmn'
ircdb.users.setUser(id, u) ircdb.users.setUser(id, u)
self.assertRegexp('sendnote inkedmn test', '#1') self.assertRegexp('note send inkedmn test', '#1')
self.assertError('sendnote alsdkjfasldk foo') self.assertError('note send alsdkjfasldk foo')
self.assertNotRegexp('sendnote inkedmn test2', 'the operation') self.assertNotRegexp('note send inkedmn test2', 'the operation')
def testNote(self): def testNote(self):
# self.assertNotError('note 1') # self.assertNotError('note 1')
self.assertError('note blah') self.assertError('note get blah')
def testNotes(self): def testNotes(self):
self.assertNotError('notes') self.assertNotError('note list')
def testOldNotes(self): def testOldNotes(self):
self.assertNotError('oldnotes') self.assertNotError('note list --old')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: