diff --git a/discorss.py b/discorss.py index 07b80a2..bf39fed 100755 --- a/discorss.py +++ b/discorss.py @@ -23,11 +23,9 @@ log_file_name = r"/app.log" def getDescription(feed): try: - tempStr = str(feed.entries[0]["summary_detail"]["value"]) - desc = tempStr[:100] if len(tempStr) > 100 else tempStr + desc = str(feed.entries[0]["summary_detail"]["value"]) except KeyError: - tempStr = str(feed.entries[0]["description"]) - desc = tempStr[:100] if len(tempStr) > 100 else tempStr + desc = str(feed.entries[0]["description"]) return desc @@ -54,33 +52,29 @@ def main(): print(feed.entries[0]["published"], published_time, now) # Generate the webhook webhook = { - "content": "RSS Feed Update from " + str(hook["name"]), "embeds": [ { "title": str(feed.entries[0]["title"]), "url": str(feed.entries[0]["link"]), - "color": 5814783, - "fields": [ - { - "name": str(feed.entries[0]["title"]), - "value": getDescription(feed), - } - ], + "description": getDescription(feed), + "provider": "DiscoRSS", } - ], - "attachments": [], + ] } customHeader = { "user-agent": "DiscoRSS (https://git.frzn.dev/amr/discorss, 0.1)", "content-type": "application/json", } - webhookStr = json.dumps(webhook) - print(webhookStr) if published_time > last_check and published_time < now: - r = requests.post(hook["webhook"], data=webhookStr, headers=customHeader) - app_config["lastupdate"] = now - with open(config_file_path, "w") as config_file: - json.dump(app_config, config_file, indent=4) + print(json.dumps(webhook)) + r = requests.post( + hook["webhook"], data=json.dumps(webhook), headers=customHeader + ) + print(webhook["embeds"][0]["title"]) + print(r.text, r.status_code, r.json()) + app_config["lastupdate"] = now + with open(config_file_path, "w") as config_file: + json.dump(app_config, config_file, indent=4) return