summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--subbot.py17
l---------subbot2.py1
2 files changed, 14 insertions, 4 deletions
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