mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Added --url option to lasturl.
This commit is contained in:
parent
0719bdec92
commit
49ef542c83
@ -200,29 +200,35 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler):
|
|||||||
"""
|
"""
|
||||||
if '--nolimit' not in args:
|
if '--nolimit' not in args:
|
||||||
args.append('--nolimit')
|
args.append('--nolimit')
|
||||||
|
while '--url' in args:
|
||||||
|
args.remove('--url')
|
||||||
self.lasturl(irc, msg, args)
|
self.lasturl(irc, msg, args)
|
||||||
|
|
||||||
def lasturl(self, irc, msg, args):
|
def lasturl(self, irc, msg, args):
|
||||||
"""[<channel>] [--{from,with,at,proto,near}=<value>] [--nolimit]
|
"""[<channel>] [--{from,with,at,proto,near}=<value>] --{nolimit,url}
|
||||||
|
|
||||||
Gives the last URL matching the given criteria. --from is from whom
|
Gives the last URL matching the given criteria. --from is from whom
|
||||||
the URL came; --at is the site of the URL; --proto is the protocol the
|
the URL came; --at is the site of the URL; --proto is the protocol the
|
||||||
URL used; --with is something inside the URL; --near is a string in the
|
URL used; --with is something inside the URL; --near is a string in the
|
||||||
messages before and after the link. If --nolimit is given, returns as
|
messages before and after the link. If --nolimit is given, returns as
|
||||||
many URLs as can fit in the message. <channel> is only necessary if the
|
many URLs as can fit in the message. --url returns just the url.
|
||||||
|
<channel> is only necessary if the
|
||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['from=', 'with=', 'at=',
|
(optlist, rest) = getopt.getopt(args, '', ['from=', 'with=', 'at=',
|
||||||
'proto=', 'near=',
|
'proto=', 'near=',
|
||||||
'nolimit'])
|
'nolimit', 'url'])
|
||||||
criteria = ['1=1']
|
criteria = ['1=1']
|
||||||
formats = []
|
formats = []
|
||||||
|
simple = False
|
||||||
nolimit = False
|
nolimit = False
|
||||||
for (option, argument) in optlist:
|
for (option, argument) in optlist:
|
||||||
option = option[2:] # Strip off the --.
|
option = option.lstrip('-') # Strip off the --.
|
||||||
if option == 'nolimit':
|
if option == 'nolimit':
|
||||||
nolimit = True
|
nolimit = True
|
||||||
|
if option == 'url':
|
||||||
|
simple = True
|
||||||
elif option == 'from':
|
elif option == 'from':
|
||||||
criteria.append('added_by LIKE %s')
|
criteria.append('added_by LIKE %s')
|
||||||
formats.append(argument)
|
formats.append(argument)
|
||||||
@ -262,6 +268,8 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler):
|
|||||||
if nolimit:
|
if nolimit:
|
||||||
urls = ['<%s>' % t[0] for t in cursor.fetchall()]
|
urls = ['<%s>' % t[0] for t in cursor.fetchall()]
|
||||||
s = ircutils.privmsgPayload(urls, ', ', 400)
|
s = ircutils.privmsgPayload(urls, ', ', 400)
|
||||||
|
elif simple:
|
||||||
|
s = cursor.fetchone()[0]
|
||||||
else:
|
else:
|
||||||
(url, added, added_by) = cursor.fetchone()
|
(url, added, added_by) = cursor.fetchone()
|
||||||
timestamp = time.strftime('%I:%M %p, %B %d, %Y',
|
timestamp = time.strftime('%I:%M %p, %B %d, %Y',
|
||||||
|
Loading…
Reference in New Issue
Block a user