问题描述
我在#telethon电报组中问了这个问题,但没有得到足够的答案。 因此,我得到了支持迁移的“代码”:
@client.on(events.Raw(types.UpdateNewChannelMessage))
async def migrate_event(event: types.UpdateNewChannelMessage):
if event.message:
if isinstance(event.message.action,types.MessageActionChannelMigrateFrom):
was_chat_id = -1 * event.message.action.chat_id
new_id = int('-100' + str(event.message.to_id.channel_id))
raise events.StopPropagation
但是当我更改组权限或某些用户的权限(例如,将其转移到管理员权限)时,它不起作用。 我得到的是这样的东西:
UpdateChatParticipants(participants=ChatParticipants(chat_id=496384744,participants=[ChatParticipant(user_id=849120097,inviter_id=382775249,date=datetime.datetime(2020,8,18,28,30,tzinfo=datetime.timezone.utc)),ChatParticipant(user_id=1038400746,ChatParticipantCreator(user_id=382775249)],version=1))
在收听原始事件时:
@client.on(events.Raw)
async def migrate_event(event):
print(event)
print(event.message.action)
我只是不太明白,尽管这是因为较旧的Telethon版本(1.12),因为较新的Telethon版本正在进行层更改(因此在安装时在setup.py中内置了其他定义),但我看到的是不同的问题。 我可能不知道该如何正确编码,而我却错过了一些知识。
那么,您知道如何正确处理它吗?
解决方法
建议的代码正在运行,您只需要对值做一些事情...
A
这应该在每个聊天事件上打印一条消息,并检测到超级组等的迁移,并打印新旧 ID。
要获得其他操作,您还必须过滤和处理它们...