diff options
author | Christian Franke <nobody@nowhere.ws> | 2013-03-17 13:52:47 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2013-03-17 13:52:47 +0100 |
commit | a99a574cae03541c75918b6874b6a05405ee8469 (patch) | |
tree | 5005421fcc793d04478b61068228c2f59309129d | |
parent | 4b98486fc70a685dd4d8cae6a8197904365c9c8c (diff) |
subbot: allow to run staging and production
-rw-r--r-- | subbot.py | 17 | ||||
l--------- | subbot2.py | 1 |
2 files changed, 14 insertions, 4 deletions
@@ -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 |