Skip to content

Commit 16e04f8

Browse files
error of simple wolfram request fix & pep8
1 parent 9585b4e commit 16e04f8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

telegram_bot/handlers/messages/equation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ def handle_equation(bot, update) -> int:
1616
chat_id=chat_id,
1717
reply_markup=ReplyKeyboardRemove()
1818
)
19-
return MenuEntry.EQUATION.value
19+
return MenuEntry.EQUATION.value

telegram_bot/handlers/messages/extrema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def handle_extrema(bot, update) -> int:
1515
chat_id=chat_id,
1616
reply_markup=ReplyKeyboardRemove()
1717
)
18-
return MenuEntry.EXTREMA.value
18+
return MenuEntry.EXTREMA.value

telegram_bot/handlers/messages/wolfram_request.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ def handle_simple_wolfram_request(
4646
) -> int:
4747
max_image_height = 640
4848
answer = make_simple_wolfram_request(request, WOLFRAM_APP_ID)
49-
if not answer:
50-
bot.send_message(
51-
chat_id=chat_id,
52-
text='Unsuccessful. Check your request and try again',
53-
reply_markup=reply_markup
54-
)
55-
else:
49+
try:
5650
image = Image.open(BytesIO(answer))
5751
answer_images = crop_image(image, max_image_height)
5852
for answer_image in answer_images:
@@ -64,6 +58,12 @@ def handle_simple_wolfram_request(
6458
photo=BytesIO(image_bytes),
6559
reply_markup=reply_markup
6660
)
61+
except OSError:
62+
bot.send_message(
63+
chat_id=chat_id,
64+
text='Unsuccessful. Check your request and try again',
65+
reply_markup=reply_markup
66+
)
6767
return MenuEntry.START_MENU.value
6868

6969

0 commit comments

Comments
 (0)