added GIF support

This commit is contained in:
CarolineHusky 2024-03-20 18:00:09 +01:00
parent d1553380be
commit 5137655a47

View file

@ -27,6 +27,10 @@ def telegram_bot_post(data):
text+="\n\n".join(data["descriptions"])
text=text.replace("@","\uFF20")
if len(data["images"])==1:
if data["images"][0].endswith(".gif"):
url="https://api.telegram.org/bot"+token+"/sendAnimation"
response=requests.post(url, data={'chat_id': chat, 'caption': text, 'caption_entities':json.dumps(entities), "reply_markup":json.dumps({"inline_keyboard": [[{"text": "Sauce...", "url": data["link"]}]]})}, files={'animation': open(os.path.join("tumblrbot",data["images"][0]),"rb")})
else:
url="https://api.telegram.org/bot"+token+"/sendPhoto"
response=requests.post(url, data={'chat_id': chat, 'caption': text, 'caption_entities':json.dumps(entities), "reply_markup":json.dumps({"inline_keyboard": [[{"text": "Sauce...", "url": data["link"]}]]})}, files={'photo': open(os.path.join("tumblrbot",data["images"][0]),"rb")})
else: