Added the note id to the response to sendnote.

This commit is contained in:
Jeremy Fincher 2003-10-23 09:16:20 +00:00
parent 589172a5f0
commit dd40523197
2 changed files with 9 additions and 7 deletions

View File

@ -158,11 +158,16 @@ class Notes(callbacks.Privmsg):
else:
public = 0
cursor = self.db.cursor()
now = int(time.time())
cursor.execute("""INSERT INTO notes VALUES
(NULL, %s, %s, %s, 0, 0, %s, %s)""",
fromId, toId, int(time.time()), public, note)
fromId, toId, now, public, note)
self.db.commit()
irc.reply(msg, conf.replySuccess)
cursor.execute("""SELECT id FROM notes WHERE
from_id=%s AND to_id=%s AND added_at=%s""",
fromId, toId, now)
id = cursor.fetchone()[0]
irc.reply(msg, 'Note #%s sent to %s.' % (id, name))
def note(self, irc, msg, args):
"""<note id>

View File

@ -42,10 +42,6 @@ except ImportError:
if sqlite is not None:
class NotesTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Notes', 'Misc', 'User')
def testHelps(self):
self.assertNotError('help sendnote')
self.assertNotError('list Notes')
def testSendnote(self):
#print repr(ircdb.users.getUser(self.prefix))
self.prefix = 'foo!bar@baz'
@ -53,8 +49,9 @@ if sqlite is not None:
(id, u) = ircdb.users.newUser()
u.name = 'inkedmn'
ircdb.users.setUser(id, u)
self.assertNotError('sendnote inkedmn test')
self.assertRegexp('sendnote inkedmn test', '#1')
self.assertError('sendnote alsdkjfasldk foo')
self.assertNotRegexp('sendnote inkedmn test2', 'the operation')
def testNote(self):
# self.assertNotError('note 1')