pininkara / BingChatBot

Bing chat Telegram bot using Python and unofficial EdgeGPT API
Apache License 2.0
54 stars 20 forks source link

callbackQuery function sometimes crashes #3

Closed kingofkillers91 closed 1 year ago

kingofkillers91 commented 1 year ago

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'
kingofkillers91 commented 1 year ago

image_2023-03-10_232354988

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

soyelmismo commented 1 year ago

start over " button

thats the fix, because if you say something unappropiate the bot closes the session then the script starts giving console errors due to await asyncio.shield(self.close_connection_task)

asyncio.exceptions.CancelledError