from telethon import TelegramClient
client = TelegramClient('anon', api_id, api_hash)
async def main():
await client.send_message(chat_id, 'Hello')
with client:
client.loop.run_until_complete(main())
When I try to run the code I get an error:
telethon.errors.rpcerrorlist.ChatIdInvalidError: Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead (caused by SendMessageRequest)
Chat's ID is correct, I checked. What could be the problem?
yes you have to confirm from your chat id and make sure you passed the correct id of your chat. you can use "@_Chat_ID" or use "htttp//t.me/Chat_link"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.