aports/testing/sopel/add-tpaste-us.patch
Kevin Daudt 54c47d9463 testing/sopel: upgrade to 7.0.0
Disabled test suite because it fails to properly run:

> ERROR sopel/__init__.py - pkg_resources.DistributionNotFound: The 'sopel'
> distribution was not found and is required by the application

Upstream issue: https://github.com/sopel-irc/sopel/issues/1846
2020-04-18 18:10:23 +00:00

35 lines
1.1 KiB
Diff

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',