argparse: add --no-connect option to disable autoconnect rules in configuration files

This commit is contained in:
nemunaire 2014-12-15 21:53:40 +01:00
parent f575674d47
commit 22a2ba76c4
2 changed files with 7 additions and 1 deletions

2
bot.py
View File

@ -326,7 +326,7 @@ class Bot(threading.Thread):
if srv.id not in self.servers:
self.servers[srv.id] = srv
if autoconnect:
if autoconnect and not hasattr(self, "noautoconnect"):
srv.open()
return True

View File

@ -32,6 +32,9 @@ if __name__ == "__main__":
# Parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--no-connect", action="store_true",
help="disable auto-connect to servers at startup")
parser.add_argument("-v", "--verbose", action="count",
default=0,
help="verbosity level")
@ -87,6 +90,9 @@ if __name__ == "__main__":
context = bot.Bot(modules_paths=modules_paths, data_path=args.data_path,
verbosity=args.verbose)
if args.no_connect:
context.noautoconnect = True
# Load the prompt
prmpt = prompt.Prompt()