feat: add --disable-command option to specify a command to disable

This commit is contained in:
Pagliacii
2023-12-15 21:39:21 +08:00
parent 384cc4656f
commit 93fb98f7b5
3 changed files with 19 additions and 2 deletions

14
tg.py
View File

@ -9,12 +9,24 @@ def main():
# Init args
parser = argparse.ArgumentParser()
parser.add_argument("tg_token", help="tg token")
# 'disable-command' option
# The action 'append' will allow multiple entries to be saved into a list
# The variable name is changed to 'disable_commands'
parser.add_argument(
"--disable-command",
action="append",
dest="disable_commands",
help="Specify a command to disable. Can be used multiple times.",
default=[],
)
options = parser.parse_args()
print("Arg parse done.")
# Init bot
bot = TeleBot(options.tg_token)
load_handlers(bot)
load_handlers(bot, options.disable_commands)
print("Bot init done.")
# Start bot