From 802786544fa9a8d637ce55c52058683b2fddd011 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 24 May 2016 23:40:02 +0200 Subject: [PATCH] Take command-line arguments --- infobot.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/infobot.py b/infobot.py index a16a7b1..c7b0fac 100644 --- a/infobot.py +++ b/infobot.py @@ -1,3 +1,4 @@ +import sys import yaboli class InfoBot(yaboli.Bot): @@ -107,5 +108,22 @@ class InfoBot(yaboli.Bot): self.room.send_message(msg, message.id) -manager = yaboli.BotManager(InfoBot, default_nick="infobot") -manager.create("bots") +def main(rooms, imode=False): + manager = yaboli.BotManager(InfoBot, default_nick="infobot") + + for room in rooms: + manager.create(room) + + #if imode: + #manager.interactive_mode() + +if __name__ == "__main__": + args = sys.argv[1:] + + if "-i" in args: + imode = True + args.remove("-i") + else: + imode=False + + main(args, imode=imode)