1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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',
|