Relative Content

Tag Archive for pythontelegramtelegram-bot

read timeout on telegram bot

Traceback (most recent call last):
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libsite-packagesurllib3connectionpool.py”, line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libsite-packagesurllib3connection.py”, line 461, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libhttpclient.py”, line 1419, in getresponse
response.begin()
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libhttpclient.py”, line 331, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libhttpclient.py”, line 292, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), “iso-8859-1”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libsocket.py”, line 707, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libssl.py”, line 1253, in recv_into
return self.read(nbytes, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersryuuAppDataLocalProgramsPythonPython312Libssl.py”, line 1105, in read
return self._sslobj.read(len, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out

User.send_message() got an unexpected keyword argument ‘chat_id’

I don’t understand why it’s not possible to write a chat message from a bot. I have configured to receive id_admin, I have configured the schedule library to receive messages at certain times, but I don’t understand why it is NOT writing me chat messages. I can see from the logs that: User.send_message() got an unexpected keyword argument ‘chat_id’

Server and Telegram bot communication

I’m new to development of Telegram bots and can’t figure out how I can implement communication between the server side and the bot.
I understand how to send messages to the server, I just send a POST-request to the server and get some kind of Response. The question is about sending request from server to the bot. I want to make a bot that when receiving a message from a user in Telegram-chat will forward this message to the server, where message will be processed, and in the response will come the result of processing, which will be sent to the user. Bot will receive in the response Json-file { ‘chatid’: 1234567,
‘result’ : “Some text message”}.
At the same time, the server will have a web interface with a button, which will be pressed to send to the bot a request with data. The data can be different. For example, I clicked button in the web-interface and the bot received a chatid and some text, after which the bot sent it to the person whose chatid was received. But just using sendMessage from the server side is not suitable for me because there may be another case when the bot will receive a request for example to remove a user from a group or publish a post in a certain channel, etc.
I can not understand how to implement the mechanism of receiving a request from the server.

How to Programmatically Clear Entire Chat History in a Telegram Bot

I’m developing a Telegram bot that sends notifications and tracks attendance for an upcoming game. I want to implement a /clean command that will erase the entire chat history for all users, essentially making it look like a new chat. This command should be available only to admins.

Debugging and Deploying a Telegram Bot for Fetching Soccer News: Issues with Consistency and Source Variety

I already have a telegram bot to search news from a brazillian soccer team, and send them during all day on a telegram channel. I’m facing problems with 2 main things. First is: when i run it locally, works well for some time, but after a fews hours, stops sending news.
Second is: it gets some news, but I was looking to get much more news, and really don’t get how to get news from others sources.
My code (credentials hidden, but all tested and working fine):

telegram doesn’t show white spaces correctly

I create a text in Python, and it displays correctly in its true shape in the terminal. However, when I use the Telegram API to send it to my channel, the white space sizes are not shown correctly. Here is a picture of the text in the terminal, and the other one is in Telegram.