我正在尝试修改此脚本,以便即使同时发送多个消息,该脚本也将继续尝试直到它们被允许通过。
原始脚本为:https://github.com/4rqm/dhooks
我的版本是:
def post(self):
"""
Send the JSON formated object to the specified `self.url`.
"""
headers = {'Content-Type': 'application/json'}
result = requests.post(self.url, data=self.json, headers=headers)
if result.status_code == 400 or result.status_code == 429:
print(result.status_code)
#its the line below that does not work.
post(self)
else:
print("Payload delivered successfuly")
print("Code : "+str(result.status_code))
time.sleep(2)