【发布时间】:2020-12-26 02:42:07
【问题描述】:
我有一个在 python 上运行并基于 Telethon 库的电报机器人。我想标记一个组中的所有成员,但我的代码源有 100 个用户标记限制,当我想将其数量增加到 500 个用户甚至更多时,它不会标记整个用户,只是给我他们的名字,只是标记前 100 个用户。请帮助我如何在不给用户计数的情况下标记组中的所有成员。代码如下:
import asyncio
from telethon import events
from telethon.tl.types import ChannelParticipantsAdmins
async def _(event):
if event.fwd_from:
return
mentions = "All members tagged successfully!"
chat = await event.get_input_chat()
async for x in borg.iter_participants(chat, 100):
mentions += f" \n [{x.first_name}](tg://user?id={x.id})"
await event.reply(mentions)
await event.delete()
我可以通过这些代码在组中标记管理员:
async def _(event):
if event.fwd_from:
return
mentions = "Administrators in the chat : "
chat = await event.get_input_chat()
async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
mentions += f" \n [{x.first_name}](tg://user?id={x.id})"
reply_message = None
if event.reply_to_msg_id:
reply_message = await event.get_reply_message()
await reply_message.reply(mentions)
else:
await event.reply(mentions)
await event.delete()
我可以在上面的代码中添加像 ChannelParticipantsAdmins 这样的过滤器,而不是在之前的代码中添加 100 个用户数吗?如果是,过滤器部分应该是什么。
感谢您的帮助。
【问题讨论】:
-
使用 pin 消息。
-
Telegram 限制了您可以在一条消息中标记的人数。上次我听说限制是 50。就像@itsapk 所说,最好只是固定并通知消息。
标签: python tags telegram telegram-bot telethon