Created
October 26, 2019 06:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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