[英]How to get messages from a group chat on Telegram?
I am having trouble understanding the Telethon API in Python. 我在理解Python中的Telethon API时遇到了麻烦。 I have created an account and have an api_id/api_hash, but I cannot connect to the server.
我已经创建了一个帐户并具有api_id / api_hash,但是我无法连接到服务器。 This is what I have:
这就是我所拥有的:
chat_id = "@thecointelegraph"
api_id = 'MYID'
api_hash = 'MYHASH'
client = TelegramClient('session_name',
api_id,
api_hash)
client.start()
I would like to download messages from a public telegram chat. 我想从公共电报聊天中下载消息。 Any help would be wonderful!
任何帮助都将是美好的! Thank you!!
谢谢!!
What is your current Code? 您当前的代码是什么? How do you know you can't connect to the Server?
您怎么知道您无法连接到服务器?
Usualy you would go about it kinda like this: 通常,您会像这样:
client = TelegramClient("username", "telegram_api", "api_hash")
client.start()
messages = client.get_message_history(dialog.entity, unread)
At least it was like this the last time, I used Telethon, I think by get_message_history was replaced by 至少上次是这样,我使用Telethon,我认为被get_message_history替换为
get_messages() get_messages()
https://lonamiwebs.github.io/Telethon/methods/messages/get_messages.html https://lonamiwebs.github.io/Telethon/methods/messages/get_messages.html
Best thing to do is work yourself through the documentary: https://telethon.readthedocs.io/en/stable/index.html 最好的办法是通过纪录片自己动手: https : //telethon.readthedocs.io/zh/stable/index.html
from telethon import TelegramClient
entity = 'session' # session_name
api_id = 123456
api_hash = '56bc70000yourhash'
client = TelegramClient(entity, api_id, api_hash)
client.start()
should work 应该管用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.