Skip to content

Commit

Permalink
help: add pastebin.ubuntu.com as help pastebin provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Streetman committed Jun 28, 2019
1 parent b105fe4 commit 13dfc18
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sopel/modules/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,31 @@ def post_to_termbin(msg):
return response.strip('\x00\n').replace('http://', 'https://', 1)


def post_to_ubuntu(msg):
data = {
'poster': 'sopel',
'syntax': 'text',
'expiration': 'day',
'content': msg,
}
try:
result = _requests_post_catch_errors('https://pastebin.ubuntu.com/', data=data)
except PostingException:
raise

if not re.match(r'https://pastebin.ubuntu.com/p/[^/]+/', result.url)
LOGGER.error("Invalid Ubuntu pastebin response url %s", result.url)
raise PostingException('Invalid response from Ubuntu pastebin: %s' % result.url)

return result.url


PASTEBIN_PROVIDERS = {
'clbin': post_to_clbin,
'0x0': post_to_0x0,
'hastebin': post_to_hastebin,
'termbin': post_to_termbin,
'ubuntu': post_to_ubuntu,
}


Expand Down

0 comments on commit 13dfc18

Please sign in to comment.