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

View File

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