StdoutCapture: add @pastebin.
parent
9f1e086e63
commit
2f48afcd9b
|
@ -51,6 +51,9 @@ StdoutCapture = conf.registerPlugin('StdoutCapture')
|
||||||
# This is where your configuration variables (if any) should go. For example:
|
# This is where your configuration variables (if any) should go. For example:
|
||||||
# conf.registerGlobalValue(StdoutCapture, 'someConfigVariableName',
|
# conf.registerGlobalValue(StdoutCapture, 'someConfigVariableName',
|
||||||
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
||||||
|
conf.registerChannelValue(StdoutCapture, 'pastebin',
|
||||||
|
registry.String('http://paste.progval.net/', _("""Default pastebin.
|
||||||
|
The pastebin has to support the LodgeIt API.""")))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
@ -90,7 +91,26 @@ class StdoutCapture(callbacks.Plugin):
|
||||||
|
|
||||||
Return the last lines displayed in the console."""
|
Return the last lines displayed in the console."""
|
||||||
irc.replies(StdoutBuffer._buffer[-number:])
|
irc.replies(StdoutBuffer._buffer[-number:])
|
||||||
history = wrap(history, ['positiveInt'])
|
history = wrap(history, ['positiveInt', 'owner'])
|
||||||
|
|
||||||
|
def pastebin(self, irc, msg, args, number, url=None):
|
||||||
|
"""<number> [<pastebin url>]
|
||||||
|
|
||||||
|
Paste the last lines displayed in the console on a pastebin and
|
||||||
|
returns the URL.
|
||||||
|
The pastebin has to support the LodgeIt API."""
|
||||||
|
base = url or self.registryValue('pastebin', msg.args[0])
|
||||||
|
if base.endswith('/'):
|
||||||
|
base = base[0:-1]
|
||||||
|
fd = utils.web.getUrlFd(base+'/json/?method=pastes.newPaste',
|
||||||
|
data=json.dumps({
|
||||||
|
'language': 'text',
|
||||||
|
'code': ''.join(StdoutBuffer._buffer[-number:]),
|
||||||
|
}),
|
||||||
|
headers={'Content-Type': 'application/json'})
|
||||||
|
irc.reply('%s/show/%s' % (base, json.load(fd)['data']))
|
||||||
|
|
||||||
|
pastebin = wrap(pastebin, ['owner', 'positiveInt', optional('text')])
|
||||||
|
|
||||||
|
|
||||||
Class = StdoutCapture
|
Class = StdoutCapture
|
||||||
|
|
Loading…
Reference in New Issue