mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Added the Web.fetch command.
This commit is contained in:
parent
c598e4cca9
commit
7e441285c7
@ -53,4 +53,9 @@ conf.registerChannelValue(Web, 'nonSnarfingRegexp',
|
|||||||
snarfed. Give the empty string if you have no URLs that you'd like to
|
snarfed. Give the empty string if you have no URLs that you'd like to
|
||||||
exclude from being snarfed."""))
|
exclude from being snarfed."""))
|
||||||
|
|
||||||
|
conf.registerGroup(Web, 'fetch')
|
||||||
|
conf.registerGlobalValue(Web.fetch, 'maximum',
|
||||||
|
registry.NonNegativeInteger(0, """Determines the maximum number of
|
||||||
|
bytes the bot will download via the 'fetch' command in this plugin."""))
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78
|
||||||
|
@ -38,8 +38,8 @@ import supybot.callbacks as callbacks
|
|||||||
|
|
||||||
class Web(callbacks.PluginRegexp):
|
class Web(callbacks.PluginRegexp):
|
||||||
"""Add the help for "@help Web" here."""
|
"""Add the help for "@help Web" here."""
|
||||||
regexps = ['titleSnarfer']
|
|
||||||
threaded = True
|
threaded = True
|
||||||
|
regexps = ['titleSnarfer']
|
||||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
super(Web, self).callCommand(command, irc, msg, *args, **kwargs)
|
super(Web, self).callCommand(command, irc, msg, *args, **kwargs)
|
||||||
@ -184,9 +184,22 @@ class Web(callbacks.PluginRegexp):
|
|||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
urlunquote = wrap(urlunquote, ['text'])
|
urlunquote = wrap(urlunquote, ['text'])
|
||||||
|
|
||||||
|
def fetch(self, irc, msg, args, url):
|
||||||
|
"""<url>
|
||||||
|
|
||||||
|
Returns the contents of <url>, or as much as is configured in
|
||||||
|
supybot.plugins.Web.fetch.maximum. If that configuration variable is
|
||||||
|
set to 0, this command will be effectively disabled.
|
||||||
|
"""
|
||||||
|
max = self.registryValue('fetch.maximum')
|
||||||
|
if not max:
|
||||||
|
irc.error('This command is disabled '
|
||||||
|
'(supybot.plugins.Web.fetch.maximum is set to 0).',
|
||||||
|
Raise=True)
|
||||||
|
fd = utils.web.getUrlFd(url)
|
||||||
|
irc.reply(fd.read(max))
|
||||||
|
fetch = wrap(fetch, ['url'])
|
||||||
|
|
||||||
Class = Web
|
Class = Web
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user