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 98a684d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sopel/modules/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""
from __future__ import unicode_literals, absolute_import, print_function, division

import re
import collections
import socket
import textwrap
Expand Down Expand Up @@ -140,11 +141,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': '',
'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 98a684d

Please sign in to comment.