我一直在寻找解决方案,但没有成功
有没有办法确保电报机器人将其所有消息发送到组中的特定 message_thread_id(topic) ?目前,当我输入命令时,机器人会回复初始频道,而不是我想要的主题。
这是我的命令之一的当前片段:
`async def add_point(update: Update, context: ContextTypes.DEFAULT_TYPE):
user = update.effective_user
chat = update.effective_chat
is_admin = user.id in [admin.user.id for admin in await context.bot.get_chat_administrators(chat.id)]
if not is_admin:
await context.bot.send_message(chat_id=chat.id, text="Only admins use this command.")
return
# check if the message is a reply to another message
if not update.message.reply_to_message:
await context.bot.send_message(chat_id=update.effective_chat.id, text="Please reply to a player to award a point.")
return`
谢谢你
我目前还没有找到可以尝试的解决方案。
您需要将线程 ID 传递给
message_thread_id
方法中的 send_message
参数。
async def add_point(update: Update, context: ContextTypes.DEFAULT_TYPE):
user = update.effective_user
chat = update.effective_chat
thread_id = update.message.message_thread_id
is_admin = user.id in [admin.user.id for admin in await context.bot.get_chat_administrators(chat.id)]
if not is_admin:
await context.bot.send_message(chat_id=chat.id, text="Only admins use this command.", message_thread_id=thread_id)
return
# check if the message is a reply to another message
if not update.message.reply_to_message:
await context.bot.send_message(chat_id=update.effective_chat.id, text="Please reply to a player to award a point.", message_thread_id=thread_id)
return