这是我的代码,我需要一种方法来获取 True/False 布尔值来确定收到的链接是否是组链接。client = TelegramClient('session', api_id, api_hash)#check whether there's a 'joinchat' in the msg text?@client.on(events.NewMessage(outgoing=False, pattern=r'(?i).*joinchat/')) async def my_event_handler(event): #extract the hash of that link hash = re.search('(?<=joinchat\/)(\w+[-]?\S\w+)', event.raw_text).group(0)
1 回答
慕斯王
TA贡献1864条经验 获得超2个赞
我想通了伙计们:
# checks whether there's a 'joinchat' in the msg text?
@client.on(events.NewMessage(outgoing=False, pattern=r'(?i).*joinchat/'))
async def my_event_handler(event):
# extracts the hash of that link
hash = re.search('(?<=joinchat\/)(\w+[-]?\S\w+)', event.raw_text).group(0)
checked = await client(CheckChatInviteRequest(hash=hash))
if checked.megagroup and checked.broadcast == False:
updates = await client(ImportChatInviteRequest(hash))
client.start()
client.run_until_disconnected()
添加回答
举报
0/150
提交
取消