這是我的代碼,我需要一種方法來獲取 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貢獻(xiàn)1864條經(jīng)驗 獲得超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
提交
取消