Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LINE 88 LINE 90
causing event.message.from_id error:
2022-12-19 16:51:10,027 - telethon.client.updates - ERROR - Unhandled exception on payment_received_handler Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\borpayment\venv\Lib\site-packages\telethon\client\updates.py", line 497, in _dispatch_update
await callback(event)
File "C:\Users\User\PycharmProjects\borpayment\main.py", line 87, in payment_received_handler
await bot.send_message(event.message.from_id, 'Thank you for buying product A!')
File "C:\Users\User\PycharmProjects\borpayment\venv\Lib\site-packages\telethon\client\messages.py", line 827, in send_message
entity = await self.get_input_entity(entity)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\PycharmProjects\borpayment\venv\Lib\site-packages\telethon\client\users.py", line 443, in get_input_entity
peer = utils.get_peer(peer)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\PycharmProjects\borpayment\venv\Lib\site-packages\telethon\utils.py", line 997, in get_peer
_raise_cast_fail(peer, 'Peer')
File "C:\Users\User\PycharmProjects\borpayment\venv\Lib\site-packages\telethon\utils.py", line 138, in _raise_cast_fail
raise TypeError('Cannot cast {} to any kind of {}.'.format(
TypeError: Cannot cast NoneType to any kind of Peer.
Changing from event.message.from_id to event.message.peer_id.user_id solves it