pininkara/BingChatBot

callbackQuery function sometimes crashes

Closed this issue · 1 comments

callbackQuery::Can you write another poem about England?
2023-03-10 23:08:45,719 (init.py:960 MainThread) ERROR - TeleBot: "Infinity polling exception: 'text'"
2023-03-10 23:08:45,721 (init.py:962 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/init.py", line 955, in infinity_polling
self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/init.py", line 1043, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/init.py", line 1118, in __threaded_polling
raise e
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/init.py", line 1074, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/util.py", line 148, in raise_exceptions
raise self.exception_info
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/util.py", line 91, in run
task(*args, **kwargs)
File "/home/alessandro/Myproject1/lib/python3.11/site-packages/telebot/init.py", line 6428, in _run_middlewares_and_handler
result = handler'function'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alessandro/Desktop/BingChatBot/bing.py", line 62, in callback_all
responseList = asyncio.run(bingChat(callbackQuery.data))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/alessandro/Desktop/BingChatBot/bing.py", line 70, in bingChat
response_dict['item']['messages'][1]['text'])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'text'

image_2023-03-10_232354988

Maybe you could add the " start over " button? Like in the pic?