Remove @url get. Add the snarfed url when replying with the tinyurl. Tests are

updated accordingly. @random will display the corresponding tinyurl when
someone decides on the display format
This commit is contained in:
James Vega 2003-11-05 20:37:39 +00:00
parent 84bff2f755
commit a46476a9ca
2 changed files with 4 additions and 22 deletions

View File

@ -50,6 +50,7 @@ import conf
import debug import debug
import utils import utils
import ircmsgs import ircmsgs
import ircutils
import privmsgs import privmsgs
import callbacks import callbacks
@ -136,8 +137,8 @@ class URL(callbacks.Privmsg, plugins.Toggleable, plugins.ChannelDBHandler):
cursor.execute("""INSERT INTO tinyurls VALUES cursor.execute("""INSERT INTO tinyurls VALUES
(NULL, %s, %s)""", id, tinyurl) (NULL, %s, %s)""", id, tinyurl)
if self.toggles.get('tinyreply', channel=msg.args[0]): if self.toggles.get('tinyreply', channel=msg.args[0]):
irc.queueMsg(callbacks.reply(msg, 'TinyURL: %s' % irc.queueMsg(callbacks.reply(msg, '%s (was %s)' %
tinyurl, prefixName=False)) (ircutils.bold(tinyurl), url), prefixName=False))
key = (msg.nick, channel) key = (msg.nick, channel)
self.nextMsgs.setdefault(key, []).append((url, added)) self.nextMsgs.setdefault(key, []).append((url, added))
db.commit() db.commit()
@ -202,24 +203,6 @@ class URL(callbacks.Privmsg, plugins.Toggleable, plugins.ChannelDBHandler):
else: else:
irc.reply(msg, url) irc.reply(msg, url)
def get(self, irc, msg, args):
"""[<channel>] <id>
Gets the URL with id <id> from the URL database for <channel>.
<channel> is only necessary if not sent in the channel itself.
"""
channel = privmsgs.getChannel(msg, args)
db = self.getDb(channel)
cursor = db.cursor()
id = privmsgs.getArgs(args)
cursor.execute("""SELECT url, added, added_by
FROM urls
WHERE id=%s""", id)
if cursor.rowcount == 0:
irc.reply(msg, 'No URL was found with that id.')
else:
irc.reply(msg, self._formatUrl(*cursor.fetchone()))
def num(self, irc, msg, args): def num(self, irc, msg, args):
"""[<channel>] """[<channel>]

View File

@ -83,7 +83,6 @@ if sqlite is not None:
self.assertRegexp('url num', str(counter)) self.assertRegexp('url num', str(counter))
self.feedMsg(url) self.feedMsg(url)
counter += 1 counter += 1
self.assertNotError('url get %s' % counter)
self.assertRegexp('url num', str(counter)) self.assertRegexp('url num', str(counter))
self.assertRegexp('url last', re.escape(urls[-1])) self.assertRegexp('url last', re.escape(urls[-1]))
@ -128,7 +127,7 @@ if sqlite is not None:
self.assertNotError('url toggle tinyreply on') self.assertNotError('url toggle tinyreply on')
self.assertRegexp('http://sourceforge.net/tracker/?'\ self.assertRegexp('http://sourceforge.net/tracker/?'\
'func=add&group_id=58965&atid=489447', 'func=add&group_id=58965&atid=489447',
r'TinyURL: http://tinyurl.com/\w{4}') r'http://tinyurl.com/\w{4}.* \(was')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: