Python telethon中的事件实体
当表情符号出现在文本中时,我对实体有问题 这是我的文字:Python telethon中的事件实体,python,entities,telethon,Python,Entities,Telethon,当表情符号出现在文本中时,我对实体有问题 这是我的文字: ❓async def handler(event): content = event.raw_text for ent, txt in event.get_entities_text(): # ent : shows you the MessageEntity constructor # txt : shows you the text interested if isin
❓async def handler(event):
content = event.raw_text
for ent, txt in event.get_entities_text():
# ent : shows you the MessageEntity constructor
# txt : shows you the text interested
if isinstance(ent, types.MessageEntityMention): # check if it's a mention
content = content.replace(txt, '@example')
❓
有关get\u entities\u text
的更多信息,请查看,偏移量是在带有代理项的文本中计算的,因此您需要在使用以下项执行操作之前添加它们:
来自telethon导入帮助程序
text=helpers.add_代理(message.raw_text)
... # 使用“text”和“message.entities”(偏移量现在就可以了)
text=helpers.del_代理项(text)#完成后删除代理项对
答案中的kill所展示的方法更适合于你的情况,但这就是在你需要的情况下它的工作原理