Skip to content

Instantly share code, notes, and snippets.

@shantanuo
Created July 17, 2025 08:31
Show Gist options
  • Save shantanuo/9258cc46551e288daf2bdbd9ae250d14 to your computer and use it in GitHub Desktop.
Save shantanuo/9258cc46551e288daf2bdbd9ae250d14 to your computer and use it in GitHub Desktop.
aksharmukha telegram bot source code
import json
import os
import requests
def lambda_handler(event, context):
request_body = json.loads(event['body'])
print (request_body)
BOT_TOKEN = os.environ.get('TOKEN')
request_msg = json.dumps(request_body['message'])
BOT_CHAT_ID = json.dumps(request_body['message']['chat']['id'])
try:
command2 = json.dumps(request_body['message']['text'][:300], ensure_ascii=False).strip('"')
except:
return {
"statusCode": 200,
"headers": {
"Content-Type": "*/*"}
}
murl = 'http://aksharamukha-plugin.appspot.com/api/public?target=IAST&text='
mresponse = requests.get(murl + str(command2)).text
mresponse = mresponse.replace('"', '')
print (mresponse)
print (BOT_TOKEN, BOT_CHAT_ID)
if command2 == '/start':
mresponse = 'Please type text in Devanagari format to convert it in IAST'
send_text = f'https://api.telegram.org/bot{BOT_TOKEN}/sendMessage?chat_id={BOT_CHAT_ID}&parse_mode=MarkdownV2&text={mresponse}'
response = requests.get(send_text)
return {
"statusCode": 200,
"headers": {
"Content-Type": "*/*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment