Folks,
Does anyone have any examples of executing an oracle query and sending the message via telegram bot in python?
Folks,
Does anyone have any examples of executing an oracle query and sending the message via telegram bot in python?
I can only answer half of your question, which is sending the message via telegram bot in python.
Creating your bot
On Telegram, search @ BotFather, send him a “/start” message
Send another “/newbot” message, then follow the instructions to setup a name and a username
Getting your Chat id
On Telegram, search your bot (by the username you just created), press the “Start” button or send a “/start” message
Open a new tab with your browser, enter https://api.telegram.org/bot/getUpdates , replace with your API token, press enter and you should see something like this:
{"ok":true,"result":[{"update_id":77xxxxxxx,
"message":{"message_id":550,"from":{"id":34xxxxxxx,"is_bot":false,"first_name":"Man Hay","last_name":"Hong","username":"manhay212","language_code":"en-HK"}
Look for “id”, for instance, 34xxxxxxx above is my chat id. Look for yours and put it as your bot_chatID in the code above
Python Code:
import requests
def telegram_bot_sendtext(bot_message):
bot_token = '<INSERT_API_KEY>'
bot_chatID = '<INSERT_CHATID>'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
response = requests.get(send_text)
return response.json()
test = telegram_bot_sendtext("Testing Telegram bot")
print(test)