From 93d94067d07ae04e18a9a93e9a1d995d8b4857e3 Mon Sep 17 00:00:00 2001 From: GLolol Date: Sun, 21 Dec 2014 22:13:27 -0500 Subject: [PATCH 1/2] Quote: add 'replace' command --- plugins/Quote/plugin.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/Quote/plugin.py b/plugins/Quote/plugin.py index 5b01f1b83..f23924a5f 100644 --- a/plugins/Quote/plugin.py +++ b/plugins/Quote/plugin.py @@ -48,6 +48,21 @@ class Quote(plugins.ChannelIdDatabasePlugin): irc.error(_('I have no quotes in my database for %s.') % channel) random = wrap(random, ['channeldb']) + def replace(self, irc, msg, args, user, channel, id, text): + """[] + Replace quote with . is only necessary if + the message isn't sent in the channel itself. + """ + try: + record = self.db.get(channel, id) + self.checkChangeAllowed(irc, msg, channel, user, record) + record.text = text + self.db.set(channel, id, record) + irc.replySuccess() + except KeyError: + self.noSuchRecord(irc, channel, id) + replace = wrap(replace, ['user', 'channeldb', 'id', 'text']) + Class = Quote # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: From 53792fbe6c7c1cd6a67268f701db651b264d05eb Mon Sep 17 00:00:00 2001 From: GLolol Date: Fri, 26 Dec 2014 17:18:08 -0500 Subject: [PATCH 2/2] Quote: add tests for 'replace' --- plugins/Quote/test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/Quote/test.py b/plugins/Quote/test.py index 48a48031a..fb0728471 100644 --- a/plugins/Quote/test.py +++ b/plugins/Quote/test.py @@ -29,8 +29,15 @@ from supybot.test import * -class QuoteTestCase(PluginTestCase): - plugins = ('Quote',) +class QuoteTestCase(ChannelPluginTestCase): + plugins = ('Quote', 'User') + def testReplace(self): + self.feedMsg('register testuser moo', to=self.nick, frm=self.prefix) + _ = self.getMsg(' ') + self.assertNotError("quote add hello") + self.assertNotError("quote replace 1 goodbye") + self.assertRegexp("quote get 1", "goodbye") + self.assertError("quote replace 5 afsdafas") # non-existant # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: