简体   繁体   English

在 Telethon 中:当我不确定我的群组/频道是私人还是公共时,如何验证 ChatAction 是否仅来自我的群组/频道?

[英]In Telethon: How can I verify If ChatAction was only from my group/channel, when I am not sure If my group/channel is private or public?

For now, I am assuming e.chat takes a specific URL of my group/channel either it's public or private and works as a filter and If any event like a user joined or left in my group/channel, it will print in the console.现在,我假设 e.chat 采用我的组/频道的特定 URL ,它是公共的或私人的,并用作过滤器,如果有任何事件,如用户加入或离开我的组/频道,它将在控制台中打印.

@bot.on(events.ChatAction(func=lambda e: not e.is_private and e.chat == "https://t.me/123"))
async def imp_fun(event):
    print(event.user_joined)

    print(event.user_left)

You can use the chats= filter:您可以使用chats=过滤器:

@bot.on(events.ChatAction(chats=[-100123456, 'username', ...]))
async def imp_fun(event):
    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM