From a99a574cae03541c75918b6874b6a05405ee8469 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Sun, 17 Mar 2013 13:52:47 +0100 Subject: subbot: allow to run staging and production --- subbot.py | 17 +++++++++++++---- subbot2.py | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) create mode 120000 subbot2.py diff --git a/subbot.py b/subbot.py index c860c17..8c9e098 100644 --- a/subbot.py +++ b/subbot.py @@ -5,6 +5,8 @@ import json, time import traceback import liblo import urllib2 +import sys +import contextlib import settings @@ -146,7 +148,8 @@ class TestBot(irc.bot.SingleServerIRCBot): def refresh(self): curtime = time.time() try: - sdata = json.load(file('/home/services/http/subcan.json', 'r')) + with contextlib.closing(urllib2.urlopen('http://taifun.local.sublab.org/subcan.json')) as json_stream: + sdata = json.load(json_stream) door = sdata[u'door.lock'] if door[u'ts'] < curtime - 120: @@ -164,9 +167,15 @@ class TestBot(irc.bot.SingleServerIRCBot): self.update_nick() self.ircobj.execute_delayed(5, self.refresh) -def main(): - bot = TestBot('#sublab', 'sublab', '172.22.24.1', 6667) +def main(nickname, channel): + bot = TestBot(channel, nickname, '172.22.24.1', 6667) bot.start() if __name__ == "__main__": - main() + if sys.argv[0] == 'subbot.py': + nickname = 'sublab' + channel = '#sublab' + else: + nickname = 'sublab2' + channel = '#sublab2' + main(nickname, channel) diff --git a/subbot2.py b/subbot2.py new file mode 120000 index 0000000..05fd28f --- /dev/null +++ b/subbot2.py @@ -0,0 +1 @@ +subbot.py \ No newline at end of file -- cgit v1.2.1