ECHO Bot exampli for Telegram and Hook.io
import requests | |
import json | |
import pprint | |
import logging | |
import microcule | |
def app(environ, start_response): | |
bottoken = 'YOUR_BOT_TOKEN' | |
baseURL = 'https://api.telegram.org/bot' | |
data = json.loads(json.dumps(Hook['params'])) | |
chat_id = data['message']['chat']['id'] | |
message = data['message']['text'] | |
data = { "chat_id" : chat_id, "text" : message } | |
sendURL = baseURL + bottoken + "/sendMessage" | |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} | |
requests.post(sendURL, data=json.dumps(data), headers=headers, verify=False) | |
start_response('200 OK', [('content-type', 'text/plain')]) | |
return '\n' | |
if __name__ == '__main__': | |
microcule.wsgi(Hook).run(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment