diff options
Diffstat (limited to 'community/sopel/add-tpaste-us.patch')
-rw-r--r-- | community/sopel/add-tpaste-us.patch | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/community/sopel/add-tpaste-us.patch b/community/sopel/add-tpaste-us.patch new file mode 100644 index 00000000000..98c48c30cfd --- /dev/null +++ b/community/sopel/add-tpaste-us.patch @@ -0,0 +1,37 @@ +Upstream: Unknown +Reason: Adds support for pasting to tpaste.us + +diff --git a/sopel/modules/help.py b/sopel/modules/help.py +index 7d8e227..c4f4f31 100644 +--- a/sopel/modules/help.py ++++ b/sopel/modules/help.py +@@ -158,6 +158,21 @@ def post_to_ubuntu(msg): + + return result.url + ++def post_to_tpaste(msg): ++ try: ++ result = _requests_post_catch_errors('https://tpaste.us/', data={'tpaste': msg}) ++ except PostingException: ++ raise ++ ++ result = result.text ++ if re.match(r'https?://tpaste\.us/', result): ++ # find/replace just in case the site tries to be sneaky and save on SSL overhead, ++ # though it will probably send us an HTTPS link without any tricks. ++ return result.replace('http://', 'https://', 1) ++ else: ++ LOGGER.error("Invalid result %s", result) ++ raise PostingException('tpaste result did not contain expected URL base.') ++ + + PASTEBIN_PROVIDERS = { + 'clbin': post_to_clbin, +@@ -165,6 +180,7 @@ PASTEBIN_PROVIDERS = { + 'hastebin': post_to_hastebin, + 'termbin': post_to_termbin, + 'ubuntu': post_to_ubuntu, ++ 'tpaste': post_to_tpaste, + } + REPLY_METHODS = [ + 'channel', |