fix management
This commit is contained in:
parent
44ef567a82
commit
b4513267ca
24
main.py
24
main.py
@ -77,16 +77,16 @@ def _add_user(bot, uid):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
def add_user(update: Update, ctx: CallbackContext, groups=(), args=()):
|
def add_user(update: Update, ctx: CallbackContext):
|
||||||
if update.callback_query:
|
if update.callback_query:
|
||||||
update.callback_query.answer()
|
update.callback_query.answer()
|
||||||
|
|
||||||
if groups:
|
if ctx.match:
|
||||||
if update.callback_query.message.chat.id != MANAGEMENT_CHAT:
|
if update.callback_query.message.chat.id != MANAGEMENT_CHAT:
|
||||||
return
|
return
|
||||||
uid = groups[0]
|
uid = ctx.match.group(1)
|
||||||
elif args:
|
elif ctx.args:
|
||||||
uid = args[0]
|
uid = ctx.args[0]
|
||||||
elif update.message and update.message.reply_to_message and update.message.reply_to_message.forward_from:
|
elif update.message and update.message.reply_to_message and update.message.reply_to_message.forward_from:
|
||||||
uid = update.message.reply_to_message.forward_from.id
|
uid = update.message.reply_to_message.forward_from.id
|
||||||
else:
|
else:
|
||||||
@ -115,16 +115,16 @@ def _remove_user(uid):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
def remove_user(update: Update, ctx: CallbackContext, groups=(), args=()):
|
def remove_user(update: Update, ctx: CallbackContext):
|
||||||
if update.callback_query:
|
if update.callback_query:
|
||||||
update.callback_query.answer()
|
update.callback_query.answer()
|
||||||
|
|
||||||
if groups:
|
if ctx.match:
|
||||||
if update.callback_query.message.chat.id != MANAGEMENT_CHAT:
|
if update.callback_query.message.chat.id != MANAGEMENT_CHAT:
|
||||||
return
|
return
|
||||||
uid = groups[0]
|
uid = ctx.match.groups(1)
|
||||||
elif args:
|
elif ctx.args:
|
||||||
uid = args[0]
|
uid = ctx.args[0]
|
||||||
elif update.message and update.message.reply_to_message and update.message.reply_to_message.forward_from:
|
elif update.message and update.message.reply_to_message and update.message.reply_to_message.forward_from:
|
||||||
uid = update.message.reply_to_message.forward_from.id
|
uid = update.message.reply_to_message.forward_from.id
|
||||||
else:
|
else:
|
||||||
@ -393,9 +393,9 @@ def main():
|
|||||||
updater.dispatcher.add_handler(CommandHandler('start', welcome, Filters.private))
|
updater.dispatcher.add_handler(CommandHandler('start', welcome, Filters.private))
|
||||||
updater.dispatcher.add_handler(CommandHandler('stop', unsubscribe, Filters.private))
|
updater.dispatcher.add_handler(CommandHandler('stop', unsubscribe, Filters.private))
|
||||||
updater.dispatcher.add_handler(CommandHandler('add', add_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
updater.dispatcher.add_handler(CommandHandler('add', add_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
||||||
updater.dispatcher.add_handler(CallbackQueryHandler(add_user, pattern=r'^add (\d+)$', pass_groups=True))
|
updater.dispatcher.add_handler(CallbackQueryHandler(add_user, pattern=r'^add (\d+)$'))
|
||||||
updater.dispatcher.add_handler(CommandHandler('remove', remove_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
updater.dispatcher.add_handler(CommandHandler('remove', remove_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
||||||
updater.dispatcher.add_handler(CallbackQueryHandler(remove_user, pattern=r'^remove (\d+)$', pass_groups=True))
|
updater.dispatcher.add_handler(CallbackQueryHandler(remove_user, pattern=r'^remove (\d+)$'))
|
||||||
updater.dispatcher.add_handler(CommandHandler('users', users_list, Filters.private))
|
updater.dispatcher.add_handler(CommandHandler('users', users_list, Filters.private))
|
||||||
updater.dispatcher.add_handler(MessageHandler(Filters.private, msg))
|
updater.dispatcher.add_handler(MessageHandler(Filters.private, msg))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user