mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
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:
parent
84bff2f755
commit
a46476a9ca
@ -50,6 +50,7 @@ import conf
|
||||
import debug
|
||||
import utils
|
||||
import ircmsgs
|
||||
import ircutils
|
||||
import privmsgs
|
||||
import callbacks
|
||||
|
||||
@ -136,8 +137,8 @@ class URL(callbacks.Privmsg, plugins.Toggleable, plugins.ChannelDBHandler):
|
||||
cursor.execute("""INSERT INTO tinyurls VALUES
|
||||
(NULL, %s, %s)""", id, tinyurl)
|
||||
if self.toggles.get('tinyreply', channel=msg.args[0]):
|
||||
irc.queueMsg(callbacks.reply(msg, 'TinyURL: %s' %
|
||||
tinyurl, prefixName=False))
|
||||
irc.queueMsg(callbacks.reply(msg, '%s (was %s)' %
|
||||
(ircutils.bold(tinyurl), url), prefixName=False))
|
||||
key = (msg.nick, channel)
|
||||
self.nextMsgs.setdefault(key, []).append((url, added))
|
||||
db.commit()
|
||||
@ -202,24 +203,6 @@ class URL(callbacks.Privmsg, plugins.Toggleable, plugins.ChannelDBHandler):
|
||||
else:
|
||||
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):
|
||||
"""[<channel>]
|
||||
|
||||
|
@ -83,7 +83,6 @@ if sqlite is not None:
|
||||
self.assertRegexp('url num', str(counter))
|
||||
self.feedMsg(url)
|
||||
counter += 1
|
||||
self.assertNotError('url get %s' % counter)
|
||||
|
||||
self.assertRegexp('url num', str(counter))
|
||||
self.assertRegexp('url last', re.escape(urls[-1]))
|
||||
@ -128,7 +127,7 @@ if sqlite is not None:
|
||||
self.assertNotError('url toggle tinyreply on')
|
||||
self.assertRegexp('http://sourceforge.net/tracker/?'\
|
||||
'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:
|
||||
|
Loading…
Reference in New Issue
Block a user