aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Renard 2019-12-17 13:22:28 -0300
committerLibravatar Renard 2019-12-17 13:22:28 -0300
commitb370dffd5bc9067c455bd54f71d5822bcca3627c (patch)
treed10076390d49dc1f87577dd0d821732908a31116
parent55289adf78990957aa80ee1ba02f5a69f41af78d (diff)
downloadweabot-b370dffd5bc9067c455bd54f71d5822bcca3627c.tar.gz
weabot-b370dffd5bc9067c455bd54f71d5822bcca3627c.tar.xz
weabot-b370dffd5bc9067c455bd54f71d5822bcca3627c.zip
Fix: Discord hook
-rw-r--r--cgi/post.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/cgi/post.py b/cgi/post.py
index 8937054..fed173b 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -1238,26 +1238,25 @@ def discord_hook(post, url):
board = Settings._.BOARD
- WEBHOOK_URL = "https://discordapp.com/api/webhooks/428025764974166018/msYu1-R3JRnG-cxrhAu3J7LbIPvzpBlJwbW5PFe5VEQaxVzjros9CXOpjZDahUE42Jgn"
+ WEBHOOK_URL = "https://discordapp.com/api/webhooks/561189208258248714/srj4woM3d87kRODV2Kn-EXoZcvjQW_NR7tGTepDNlyxWwX6gtKtVCq-rUa0D0jjAGi-4"
- data = {"content": "",
- "ts": post['timestamp'],
+ data = {
"embeds": [{
"title": post['subject'],
- "description": cut_home_msg(post['message'], 30),
- "url": "https://bienvenidoainternet.org" + url, # TODO: Parametrizar.
+ "description": "```%s```" % cut_home_msg(post['message'], 30),
+ "url": "https://bienvenidoainternet.org" + url,
"color": 11910504,
"timestamp": datetime.datetime.utcfromtimestamp(post['timestamp']).isoformat(),
- "footer": { "text": board['name'] },
+ "footer": {"text": "/%s/ - %s" % (board['dir'], board['name'])},
"thumbnail": { "url": "%s%s/thumb/%s" % (Settings.HOME_URL, board['dir'], post['thumb']) },
"author": {
"name": "Nuevo hilo",
- "icon_url": "%s0/junk/w/shobon.gif" % Settings.HOME_URL
+ "icon_url": "https://bienvenidoainternet.org/favicon.ico"
}}]
}
jsondata = json.dumps(data, separators=(',',':'))
opener = urllib2.build_opener()
- opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0')]
+ opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0'), ('Content-type', 'application/json')]
response = opener.open(Settings.DISCORD_HOOK_URL, jsondata, 6)
the_page = response.read()