Skip to content

Instantly share code, notes, and snippets.

@sanudatta11
Created October 26, 2019 06:48
Show Gist options
  • Save sanudatta11/5d8ad87588283c9ff745662b66663ceb to your computer and use it in GitHub Desktop.
Save sanudatta11/5d8ad87588283c9ff745662b66663ceb to your computer and use it in GitHub Desktop.
This is the Code for Telegram Echo Bot. Put your Bot Token ID in Environment with Key TOKEN
import json
import os
from botocore.vendored import requests
TOKEN = os.environ['TOKEN']
API = "https://api.telegram.org/bot{}/".format(TOKEN)
def send_message(text, chat_id):
final_text = "Your Message was: " + text
url = API + "sendMessage?text={}&chat_id={}".format(final_text, chat_id)
requests.get(url)
def lambda_handler(event, context):
message = json.loads(event['body'])
chat_id = message['message']['chat']['id']
reply = message['message']['text']
send_message(reply, chat_id)
return {
'statusCode': 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment