F33RNI / GPT-Telegramus

💜 The best free Telegram bot for ChatGPT, Microsoft Copilot (aka Bing AI / Sidney / EdgeGPT), Microsoft Copilot Designer (aka BingImageCreator), Gemini and Groq with stream writing, requests with images, multiple languages, admin control, data logging and more!
GNU Affero General Public License v3.0
332 stars 104 forks source link

Add command to restart telegram bot #15

Closed WangBoee closed 1 year ago

WangBoee commented 1 year ago

Sometimes, messages to bot are always in queue (Add to the queue. Position: x/5 ),and no any response. I have to restart docker container manually then it will be working again. Is it possible to add a command like /restart which can restart the program automatically?

There's some log below while bot not answering.

2023-02-27 22:04:46 ERROR No error handlers are registered, logging exception. Traceback (most recent call last): File "h2/connection.py", line 224, in process_input KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_WINDOW_UPDATE: 13>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "httpcore/_async/http2.py", line 112, in handle_async_request File "httpcore/_async/http2.py", line 229, in _receive_response File "httpcore/_async/http2.py", line 260, in _receive_stream_event File "httpcore/_async/http2.py", line 281, in _receive_events File "httpcore/_async/http2.py", line 343, in _read_incoming_data File "h2/connection.py", line 1463, in receive_data File "h2/connection.py", line 1487, in _receive_frame File "h2/connection.py", line 1728, in _receive_window_update_frame File "h2/connection.py", line 228, in process_input h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "httpx/_transports/default.py", line 60, in map_httpcore_exceptions File "httpx/_transports/default.py", line 353, in handle_async_request File "httpcore/_async/connection_pool.py", line 253, in handle_async_request File "httpcore/_async/connection_pool.py", line 237, in handle_async_request File "httpcore/_async/connection.py", line 90, in handle_async_request File "httpcore/_async/http2.py", line 142, in handle_async_request httpcore.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "telegram/request/_httpxrequest.py", line 199, in do_request File "httpx/_client.py", line 1533, in request File "httpx/_client.py", line 1620, in send File "httpx/_client.py", line 1648, in _send_handling_auth File "httpx/_client.py", line 1685, in _send_handling_redirects File "httpx/_client.py", line 1722, in _send_single_request File "httpx/_transports/default.py", line 353, in handle_async_request File "contextlib.py", line 137, in exit File "httpx/_transports/default.py", line 77, in map_httpcore_exceptions httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "telegram/ext/_updater.py", line 607, in _network_loop_retry File "telegram/ext/_updater.py", line 335, in polling_action_cb File "telegram/ext/_updater.py", line 320, in polling_action_cb File "telegram/ext/_extbot.py", line 524, in get_updates File "telegram/_bot.py", line 331, in decorator File "telegram/_bot.py", line 3510, in get_updates File "telegram/_bot.py", line 419, in _post File "telegram/ext/_extbot.py", line 306, in _do_post File "telegram/_bot.py", line 450, in _do_post File "telegram/request/_baserequest.py", line 165, in post File "telegram/request/_baserequest.py", line 288, in _request_wrapper File "telegram/request/_baserequest.py", line 274, in _request_wrapper File "telegram/request/_httpxrequest.py", line 223, in do_request telegram.error.NetworkError: httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

F33RNI commented 1 year ago

I got the same error recently. I think this is a telegram bot error

I tried adding exception catching and restarting polling. Now I'm testing, if it works, I'll release it

https://github.com/F33RNI/GPT-Telegramus/pull/16

F33RNI commented 1 year ago

And adding a command to completely restart the application is a good idea. I'll think about it

F33RNI commented 1 year ago

How long after launching the bot did you get this error?

Sometimes, messages to bot are always in queue (Add to the queue. Position: x/5 ),and no any response. I have to restart docker container manually then it will be working again. Is it possible to add a command like /restart which can restart the program automatically?

There's some log below while bot not answering.

2023-02-27 22:04:46 ERROR No error handlers are registered, logging exception. Traceback (most recent call last): File "h2/connection.py", line 224, in process_input KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_WINDOW_UPDATE: 13>) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpcore/_async/http2.py", line 112, in handle_async_request File "httpcore/_async/http2.py", line 229, in _receive_response File "httpcore/_async/http2.py", line 260, in _receive_stream_event File "httpcore/_async/http2.py", line 281, in _receive_events File "httpcore/_async/http2.py", line 343, in _read_incoming_data File "h2/connection.py", line 1463, in receive_data File "h2/connection.py", line 1487, in _receive_frame File "h2/connection.py", line 1728, in _receive_window_update_frame File "h2/connection.py", line 228, in process_input h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpx/_transports/default.py", line 60, in map_httpcore_exceptions File "httpx/_transports/default.py", line 353, in handle_async_request File "httpcore/_async/connection_pool.py", line 253, in handle_async_request File "httpcore/_async/connection_pool.py", line 237, in handle_async_request File "httpcore/_async/connection.py", line 90, in handle_async_request File "httpcore/_async/http2.py", line 142, in handle_async_request httpcore.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/request/_httpxrequest.py", line 199, in do_request File "httpx/_client.py", line 1533, in request File "httpx/_client.py", line 1620, in send File "httpx/_client.py", line 1648, in _send_handling_auth File "httpx/_client.py", line 1685, in _send_handling_redirects File "httpx/_client.py", line 1722, in _send_single_request File "httpx/_transports/default.py", line 353, in handle_async_request File "contextlib.py", line 137, in exit File "httpx/_transports/default.py", line 77, in map_httpcore_exceptions httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/ext/_updater.py", line 607, in _network_loop_retry File "telegram/ext/_updater.py", line 335, in polling_action_cb File "telegram/ext/_updater.py", line 320, in polling_action_cb File "telegram/ext/_extbot.py", line 524, in get_updates File "telegram/_bot.py", line 331, in decorator File "telegram/_bot.py", line 3510, in get_updates File "telegram/_bot.py", line 419, in _post File "telegram/ext/_extbot.py", line 306, in _do_post File "telegram/_bot.py", line 450, in _do_post File "telegram/request/_baserequest.py", line 165, in post File "telegram/request/_baserequest.py", line 288, in _request_wrapper File "telegram/request/_baserequest.py", line 274, in _request_wrapper File "telegram/request/_httpxrequest.py", line 223, in do_request telegram.error.NetworkError: httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

speedster commented 1 year ago

How long after launching the bot did you get this error?

Sometimes, messages to bot are always in queue (Add to the queue. Position: x/5 ),and no any response. I have to restart docker container manually then it will be working again. Is it possible to add a command like /restart which can restart the program automatically? There's some log below while bot not answering.

2023-02-27 22:04:46 ERROR No error handlers are registered, logging exception. Traceback (most recent call last): File "h2/connection.py", line 224, in process_input KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_WINDOW_UPDATE: 13>) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpcore/_async/http2.py", line 112, in handle_async_request File "httpcore/_async/http2.py", line 229, in _receive_response File "httpcore/_async/http2.py", line 260, in _receive_stream_event File "httpcore/_async/http2.py", line 281, in _receive_events File "httpcore/_async/http2.py", line 343, in _read_incoming_data File "h2/connection.py", line 1463, in receive_data File "h2/connection.py", line 1487, in _receive_frame File "h2/connection.py", line 1728, in _receive_window_update_frame File "h2/connection.py", line 228, in process_input h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpx/_transports/default.py", line 60, in map_httpcore_exceptions File "httpx/_transports/default.py", line 353, in handle_async_request File "httpcore/_async/connection_pool.py", line 253, in handle_async_request File "httpcore/_async/connection_pool.py", line 237, in handle_async_request File "httpcore/_async/connection.py", line 90, in handle_async_request File "httpcore/_async/http2.py", line 142, in handle_async_request httpcore.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/request/_httpxrequest.py", line 199, in do_request File "httpx/_client.py", line 1533, in request File "httpx/_client.py", line 1620, in send File "httpx/_client.py", line 1648, in _send_handling_auth File "httpx/_client.py", line 1685, in _send_handling_redirects File "httpx/_client.py", line 1722, in _send_single_request File "httpx/_transports/default.py", line 353, in handle_async_request File "contextlib.py", line 137, in exit File "httpx/_transports/default.py", line 77, in map_httpcore_exceptions httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/ext/_updater.py", line 607, in _network_loop_retry File "telegram/ext/_updater.py", line 335, in polling_action_cb File "telegram/ext/_updater.py", line 320, in polling_action_cb File "telegram/ext/_extbot.py", line 524, in get_updates File "telegram/_bot.py", line 331, in decorator File "telegram/_bot.py", line 3510, in get_updates File "telegram/_bot.py", line 419, in _post File "telegram/ext/_extbot.py", line 306, in _do_post File "telegram/_bot.py", line 450, in _do_post File "telegram/request/_baserequest.py", line 165, in post File "telegram/request/_baserequest.py", line 288, in _request_wrapper File "telegram/request/_baserequest.py", line 274, in _request_wrapper File "telegram/request/_httpxrequest.py", line 223, in do_request telegram.error.NetworkError: httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

Three to seven times a week.

WangBoee commented 1 year ago

How long after launching the bot did you get this error?

Sometimes, messages to bot are always in queue (Add to the queue. Position: x/5 ),and no any response. I have to restart docker container manually then it will be working again. Is it possible to add a command like /restart which can restart the program automatically? There's some log below while bot not answering.

2023-02-27 22:04:46 ERROR No error handlers are registered, logging exception. Traceback (most recent call last): File "h2/connection.py", line 224, in process_input KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_WINDOW_UPDATE: 13>) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpcore/_async/http2.py", line 112, in handle_async_request File "httpcore/_async/http2.py", line 229, in _receive_response File "httpcore/_async/http2.py", line 260, in _receive_stream_event File "httpcore/_async/http2.py", line 281, in _receive_events File "httpcore/_async/http2.py", line 343, in _read_incoming_data File "h2/connection.py", line 1463, in receive_data File "h2/connection.py", line 1487, in _receive_frame File "h2/connection.py", line 1728, in _receive_window_update_frame File "h2/connection.py", line 228, in process_input h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpx/_transports/default.py", line 60, in map_httpcore_exceptions File "httpx/_transports/default.py", line 353, in handle_async_request File "httpcore/_async/connection_pool.py", line 253, in handle_async_request File "httpcore/_async/connection_pool.py", line 237, in handle_async_request File "httpcore/_async/connection.py", line 90, in handle_async_request File "httpcore/_async/http2.py", line 142, in handle_async_request httpcore.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/request/_httpxrequest.py", line 199, in do_request File "httpx/_client.py", line 1533, in request File "httpx/_client.py", line 1620, in send File "httpx/_client.py", line 1648, in _send_handling_auth File "httpx/_client.py", line 1685, in _send_handling_redirects File "httpx/_client.py", line 1722, in _send_single_request File "httpx/_transports/default.py", line 353, in handle_async_request File "contextlib.py", line 137, in exit File "httpx/_transports/default.py", line 77, in map_httpcore_exceptions httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/ext/_updater.py", line 607, in _network_loop_retry File "telegram/ext/_updater.py", line 335, in polling_action_cb File "telegram/ext/_updater.py", line 320, in polling_action_cb File "telegram/ext/_extbot.py", line 524, in get_updates File "telegram/_bot.py", line 331, in decorator File "telegram/_bot.py", line 3510, in get_updates File "telegram/_bot.py", line 419, in _post File "telegram/ext/_extbot.py", line 306, in _do_post File "telegram/_bot.py", line 450, in _do_post File "telegram/request/_baserequest.py", line 165, in post File "telegram/request/_baserequest.py", line 288, in _request_wrapper File "telegram/request/_baserequest.py", line 274, in _request_wrapper File "telegram/request/_httpxrequest.py", line 223, in do_request telegram.error.NetworkError: httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

Three to seven times a week.

Almost that situation, I'm not sure.

speedster commented 1 year ago

How long after launching the bot did you get this error?

Sometimes, messages to bot are always in queue (Add to the queue. Position: x/5 ),and no any response. I have to restart docker container manually then it will be working again. Is it possible to add a command like /restart which can restart the program automatically? There's some log below while bot not answering.

2023-02-27 22:04:46 ERROR No error handlers are registered, logging exception. Traceback (most recent call last): File "h2/connection.py", line 224, in process_input KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_WINDOW_UPDATE: 13>) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpcore/_async/http2.py", line 112, in handle_async_request File "httpcore/_async/http2.py", line 229, in _receive_response File "httpcore/_async/http2.py", line 260, in _receive_stream_event File "httpcore/_async/http2.py", line 281, in _receive_events File "httpcore/_async/http2.py", line 343, in _read_incoming_data File "h2/connection.py", line 1463, in receive_data File "h2/connection.py", line 1487, in _receive_frame File "h2/connection.py", line 1728, in _receive_window_update_frame File "h2/connection.py", line 228, in process_input h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED During handling of the above exception, another exception occurred: Traceback (most recent call last): File "httpx/_transports/default.py", line 60, in map_httpcore_exceptions File "httpx/_transports/default.py", line 353, in handle_async_request File "httpcore/_async/connection_pool.py", line 253, in handle_async_request File "httpcore/_async/connection_pool.py", line 237, in handle_async_request File "httpcore/_async/connection.py", line 90, in handle_async_request File "httpcore/_async/http2.py", line 142, in handle_async_request httpcore.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/request/_httpxrequest.py", line 199, in do_request File "httpx/_client.py", line 1533, in request File "httpx/_client.py", line 1620, in send File "httpx/_client.py", line 1648, in _send_handling_auth File "httpx/_client.py", line 1685, in _send_handling_redirects File "httpx/_client.py", line 1722, in _send_single_request File "httpx/_transports/default.py", line 353, in handle_async_request File "contextlib.py", line 137, in exit File "httpx/_transports/default.py", line 77, in map_httpcore_exceptions httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED The above exception was the direct cause of the following exception: Traceback (most recent call last): File "telegram/ext/_updater.py", line 607, in _network_loop_retry File "telegram/ext/_updater.py", line 335, in polling_action_cb File "telegram/ext/_updater.py", line 320, in polling_action_cb File "telegram/ext/_extbot.py", line 524, in get_updates File "telegram/_bot.py", line 331, in decorator File "telegram/_bot.py", line 3510, in get_updates File "telegram/_bot.py", line 419, in _post File "telegram/ext/_extbot.py", line 306, in _do_post File "telegram/_bot.py", line 450, in _do_post File "telegram/request/_baserequest.py", line 165, in post File "telegram/request/_baserequest.py", line 288, in _request_wrapper File "telegram/request/_baserequest.py", line 274, in _request_wrapper File "telegram/request/_httpxrequest.py", line 223, in do_request telegram.error.NetworkError: httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_WINDOW_UPDATE in state ConnectionState.CLOSED

Most of the time we started bot but didn't use it. So I don't know exactly.

F33RNI commented 1 year ago

OK. Try the code from the next branch (https://github.com/F33RNI/GPT-Telegramus/pull/16). I will also leave it for a few hours, let's see if the error occurs again 🙃

WangBoee commented 1 year ago

OK. Try the code from the next branch (#16). I will also leave it for a few hours, let's see if the error occurs again 🙃

I've tried the docker image from the next branch docker pull ghcr.io/f33rni/gpt-telegramus:next And the log showed that it started successfully.

2023-02-28 16:51:34 INFO Proxy checks disabled. Initializing chatbot... 2023-02-28 16:51:34 INFO AIHandler thread: Thread-1 2023-02-28 16:51:34 INFO Responses handler background thread: Thread-2 telegram/ext/_applicationbuilder.py:303: PTBUserWarning: Application instances should be built via the ApplicationBuilder. 2023-02-28 16:51:34 INFO Application started

Unfortunately, the bot didn't respond to any message I sent, including 'Added to the queue. Position: x/5'. And there's no any logs printed.

F33RNI commented 1 year ago

https://github.com/F33RNI/GPT-Telegramus/pull/16

F33RNI commented 1 year ago

https://github.com/F33RNI/GPT-Telegramus/releases/tag/beta_1.8.0