[英]How can I Identify a bot on telethon event updater
I'm making a bot to forward all receiving messages on telegram.我正在制作一个机器人来转发所有接收到的电报消息。
from telethon import TelegramClient
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = TelegramClient('anon', api_id, api_hash)
log_channel=-1002030404403
async def main():
async for message in client.iter_messages('me'):
print(message.id, message.text)
if event.is_private:
await client.forward_messages(log_channel, event.message)
with client:
client.loop.run_until_complete(main())
but this is not identifying different of bot and a user how to filter a bots但这并不能识别机器人和用户如何过滤机器人的不同之处
event.sender.bot
will be True
if the sender
is a bot
.如果sender
是bot
,则event.sender.bot
将为True
。
You can find this in the quick reference for Message
, where it says "It bases ChatGetter and SenderGetter.", meaning .sender
exists.您可以在Message
的快速参考中找到它,其中显示“它基于 ChatGetter 和 SenderGetter。”,这意味着.sender
存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.