Emoji in channel name seems to give an error
Opened this issue · 2 comments
When I do a list of the channels I get the following error. The channel uses emoji's in the channel name. Perhaps this is the same as the other open issue about emoji's, but I'm not sure so I opened up this new issue. If it's the same you can close it. Thanks.
Traceback (most recent call last):
File "c:\apps\telegrampy\Telegram-Autoforwarder-master\TelegramForwarder.py", line 124, in
asyncio.run(main())
File "C:\apps\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\apps\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\apps\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "c:\apps\telegrampy\Telegram-Autoforwarder-master\TelegramForwarder.py", line 111, in main
await forwarder.list_chats()
File "c:\apps\telegrampy\Telegram-Autoforwarder-master\TelegramForwarder.py", line 26, in list_chats
chats_file.write(f"Chat ID: {dialog.id}, Title: {dialog.title} \n")
File "C:\apps\Python312\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f981' in position 42: character maps to
Where to enter bot token bro and how to use in koyeb
i fixed the problem simply modifing the TelegramForwarder.py at line 26
from
chats_file = open(f"chats_of_{self.phone_number}.txt", "w")
to
chats_file = open(f"chats_of_{self.phone_number}.txt", "w", encoding="utf-8")
And it works for me