[英]Error when sending a message to telegram chat using Python Telethon
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())
当我尝试运行代码时出现错误:
telethon.errors.rpcerrorlist.ChatIdInvalidError:聊天的 object ID 无效。 确保传递正确的类型,例如确保请求是为聊天(而不是频道/巨型组)设计的,或者寻找更合适的其他类型\n使用巨型组和 AddChatUserRequest 的示例,它将失败,因为巨型组是渠道。 改用 InviteToChannelRequest(由 SendMessageRequest 引起)
聊天的ID是正确的,我检查了。 可能是什么问题呢?
是的,您必须从您的聊天 ID 进行确认,并确保您传递了正确的聊天 ID。 您可以使用“@_Chat_ID”或使用“htttp//t.me/Chat_link”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.