mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
More work on the #17
This commit is contained in:
parent
b41a9fd355
commit
b21098b7ab
13
rcgcdw.py
13
rcgcdw.py
|
@ -41,10 +41,7 @@ else:
|
||||||
_ = lambda s: s
|
_ = lambda s: s
|
||||||
|
|
||||||
def send(message, name, avatar):
|
def send(message, name, avatar):
|
||||||
try:
|
send_to_discord({"content": message, "avatar_url": avatar, "username": name})
|
||||||
req = requests.post(settings["webhookURL"], data={"content": message, "avatar_url": avatar, "username": name}, timeout=10)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def safe_read(request, *keys):
|
def safe_read(request, *keys):
|
||||||
if request is None:
|
if request is None:
|
||||||
|
@ -351,11 +348,7 @@ def webhook_formatter(action, STATIC, **params):
|
||||||
data["embeds"].append(dict(embed))
|
data["embeds"].append(dict(embed))
|
||||||
data['avatar_url'] = settings["avatars"]["embed"]
|
data['avatar_url'] = settings["avatars"]["embed"]
|
||||||
formatted_embed = json.dumps(data, indent=4)
|
formatted_embed = json.dumps(data, indent=4)
|
||||||
headers = {'Content-Type': 'application/json'}
|
send_to_discord(formatted_embed)
|
||||||
#logging.debug(data)
|
|
||||||
result = requests.post(settings["webhookURL"], data=formatted_embed, headers=headers)
|
|
||||||
if result.status_code != requests.codes.ok:
|
|
||||||
handle_discord_http(result.status_code, formatted_embed, headers)
|
|
||||||
|
|
||||||
def handle_discord_http(code, formatted_embed):
|
def handle_discord_http(code, formatted_embed):
|
||||||
if code <300 and code > 199: #message went through
|
if code <300 and code > 199: #message went through
|
||||||
|
@ -619,7 +612,7 @@ class recent_changes_class(object):
|
||||||
if self.unsent_messages:
|
if self.unsent_messages:
|
||||||
for num, item in enumerate(self.unsent_messages):
|
for num, item in enumerate(self.unsent_messages):
|
||||||
if send_to_discord_webhook(item) < 2:
|
if send_to_discord_webhook(item) < 2:
|
||||||
pass
|
time.sleep(2.5)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
self.unsent_messages = self.unsent_messages[num-1:]
|
self.unsent_messages = self.unsent_messages[num-1:]
|
||||||
|
|
Loading…
Reference in a new issue