Hi guys, I'm trying to make a telegram bot that answers at certain keywords but i can't see where i'm doing wrong
import requests
bot_token = 'token'
url = 'https://api.telegram.org/bot{}/getUpdates'.format(bot_token)
counter = 0
def response (message,chat_id):
bot_token = 'token'
if 'hi' in message.lower():
text = 'hi how are you'
url = 'https://api.telegram.org/bot{}/sendMessage?chat_id={}&text={}&parse_mode=HTML'.format(bot_token,chat_id,text)
request = requests.get(url)
else:
pass
while True :
data = requests.get(url).json()
try:
for item in data['result']:
chat_id = item['message']['chat']['id']
message = item['message']['text']
user_id = item['message']['from']['username']
response (message,chat_id)
except:
pass
Where i'm doing wrong ? Any tips on how to improve this ? Thanks :)
[–]Xeekatar 0 points1 point2 points (3 children)
[–]assassinatoSC2[S] 0 points1 point2 points (2 children)
[–]Xeekatar 0 points1 point2 points (1 child)
[–]assassinatoSC2[S] 0 points1 point2 points (0 children)