Skip to content

Commit a4119c0

Browse files
authored
Merge pull request cherrytea-dev#562 from volodkindv/fix-ReplyKeyboardMarkup-3
fix: KeyError
2 parents 3406805 + a0d650b commit a4119c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/communicate/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
KeyboardButton,
2222
ReplyKeyboardMarkup,
2323
ReplyKeyboardRemove,
24+
TelegramObject,
2425
Update,
2526
)
2627
from telegram.ext import Application, ContextTypes
@@ -2108,7 +2109,8 @@ def make_api_call(method: str, bot_api_token: str, params: dict, call_context=''
21082109

21092110
url = f'https://api.telegram.org/bot{bot_api_token}/{method}' # e.g. sendMessage
21102111
headers = {'Content-Type': 'application/json'}
2111-
if isinstance(params['reply_markup'], ReplyKeyboardMarkup):
2112+
2113+
if 'reply_markup' in params and isinstance(params['reply_markup'], TelegramObject):
21122114
params['reply_markup'] = params['reply_markup'].to_dict()
21132115
logging.info(f'({method=}, {call_context=})..before json_params = json.dumps(params) {params=}; {type(params)=}')
21142116
json_params = json.dumps(params)

0 commit comments

Comments
 (0)