我正在尝试使用“context.bot.kick_chat_member”实现自踢命令 但是,它给出了错误: AttributeError:“ExtBot”对象没有属性“kick_chat_member”
这是我的代码:
async def Z(update, context):
await context.bot.kick_chat_member(chat_id=update.effective_chat.id, user_id=update.effective_user.id, timeout=int(time.time() + 86400)) # expiry after 24h
if __name__ == '__main__':
application = ApplicationBuilder().token(TOKEN).build()
start_handler = CommandHandler('start', start)
application.add_handler(start_handler)
application.add_handler(CallbackQueryHandler(callback_query_handler))
# Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO
conv_handler = ConversationHandler(
entry_points=[CommandHandler("image", image)],
states={
GENDER: [MessageHandler(filters.Regex("^(Art|Anime|Hent)$"), gender)],
PHOTO: [MessageHandler(filters.PHOTO, photo), CommandHandler("skip", skip_photo)],
BIO: [MessageHandler(filters.TEXT & ~filters.COMMAND, bio)],
},
fallbacks=[CommandHandler("cancel", cancel)],
)
application.add_handler(conv_handler)
application.add_handler(CommandHandler('Z', Z))
application.run_polling()
注意:其他 context.bot 命令正在运行,例如:
await context.bot.send_message(chat_id=update.effective_chat.id, text= str(update.effective_user.first_name) + ", hello")
await context.bot.delete_message(chat_id=update.effective_chat.id, message_id=messages[i])
我在努力 context.bot.kick_chat_member(chat_id=update.effective_chat.id, user_id=update.effective_user.id, timeout=int(time.time() + 86400))
那没有用,我希望有人建议使用哪种方法来让机器人踢成员或如何让 context.bot.kick_chat_member 工作。