From b370dffd5bc9067c455bd54f71d5822bcca3627c Mon Sep 17 00:00:00 2001 From: Renard Date: Tue, 17 Dec 2019 13:22:28 -0300 Subject: Fix: Discord hook --- cgi/post.py | 15 +++++++-------- 1 file 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() -- cgit v1.2.1-18-gbd029