Skip to content

Commit b13302d

Browse files
authored
feat: Update aws-python-telegram-bot to v3 and using httpApi (#697)
1 parent e6a8824 commit b13302d

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

aws-python-telegram-bot/handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def webhook(event, context):
4545
bot = configure_telegram()
4646
logger.info('Event: {}'.format(event))
4747

48-
if event.get('httpMethod') == 'POST' and event.get('body'):
48+
if event.get('requestContext', {}).get('http', {}).get('method') == 'POST' and event.get('body'):
4949
logger.info('Message received')
5050
update = telegram.Update.de_json(json.loads(event.get('body')), bot)
5151
chat_id = update.message.chat.id
@@ -72,7 +72,7 @@ def set_webhook(event, context):
7272
logger.info('Event: {}'.format(event))
7373
bot = configure_telegram()
7474
url = 'https://{}/{}/'.format(
75-
event.get('headers').get('Host'),
75+
event.get('headers').get('host'),
7676
event.get('requestContext').get('stage'),
7777
)
7878
webhook = bot.set_webhook(url)

aws-python-telegram-bot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"author": "jonatasbaldin",
1616
"license": "MIT",
1717
"dependencies": {
18-
"serverless-python-requirements": "^3.0.9"
18+
"serverless-python-requirements": "^5.4.0"
1919
},
2020
"bugs": {
2121
"url": "https://github.com/jonatasbaldin/serverless-telegram-bot/issues"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-telegram-bot==8.1.1
1+
python-telegram-bot==13.11

aws-python-telegram-bot/serverless.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ functions:
1111
webhook:
1212
handler: handler.webhook
1313
events:
14-
- http: POST /
14+
- httpApi:
15+
path: /
16+
method: POST
1517

1618
set_webhook:
1719
handler: handler.set_webhook
1820
events:
19-
- http: POST /set_webhook
21+
- httpApi:
22+
path: /set_webhook
23+
method: POST
2024

2125
plugins:
2226
- serverless-python-requirements

0 commit comments

Comments
 (0)