conservation.get_response() TypeError: '<' not supported between instances of 'float' and 'NoneType'
Code that causes the issue
from telethon import TelegramClient
async def create_bot(client : TelegramClient, username):
conservation = client.conversation("@BotFather", exclusive=False)
msg = await conservation.send_message('/newbot')
response = await conservation.get_response()
Expected behavior
Get response from botfather
Actual behavior
Got error
Traceback
File "c:\Скрипты\LightLite\init_userbot\init.py", line 16, in initialize
result = await create_bot(client, bot_username)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Скрипты\LightLite\init_userbot\load_bot.py", line 37, in create_bot
response = await conservation.get_response(timeout=5)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\telethon\tl\custom\conversation.py", line 157, in get_response
return self._get_message(
~~~~~~~~~~~~~~~~~^
message, self._response_indices, self._pending_responses, timeout,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lambda x, y: True
^^^^^^^^^^^^^^^^^
)
^
File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\telethon\tl\custom\conversation.py", line 230, in _get_message
return self._get_result(future, start_time, timeout, pending, target_id)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\telethon\tl\custom\conversation.py", line 22, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\telethon\tl\custom\conversation.py", line 439, in _get_result
due = min(due, start_time + timeout)
TypeError: '<' not supported between instances of 'float' and 'NoneType'
Telethon version
1.39.0
Python version
3.13.3
Operating system (including distribution name and version)
Windows 11 Pro 22H2
Other details
I tried to add "timeout=5", but didnt helped
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't an open duplicate.
- [x] I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zipand triggered the bug in the latest version.
why no answer :(
I have no intention to maintain conversation myself (which is why v2 removes it).
i gotchu i will try to recode it myself because conservation is nice
Thanks, and feel free to send a pull request if you find a fix.
i see due is None, checking why...
I got it
at start, self._total_due = None
in function aenter if self._total_timeout: self._total_due = time.time() + self._total_timeout else: self._total_due = float('inf') but this function isnt calling
for some reason, after fixing, its gives TimeoutError, need to check why
its hard for me, so, i cant fix it :( (and im lazy)
but what i found:
- due in _get_result may be None, so, i changed some code to
if timeout is None:
timeout = self._timeout
if timeout:
due = time.time() + timeout
else:
due = float('inf')
if timeout is not None:
print(due, start_time, timeout)
due = min(due, start_time + timeout)
- I think, its not reading new messages, because incoming list is empty.