summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean B. Palmer <sean@miscoranda.com>2012-01-14 22:55:59 +0000
committerSean B. Palmer <sean@miscoranda.com>2012-01-14 22:55:59 +0000
commit436d610ff44a66443aa9417ada7de1fd386e0f6c (patch)
treec94e92399252345464a1f141cc389ec62a52d7b8
parent25755360786dcafc798d68f147471de0bbfb1056 (diff)
downloadbot-436d610ff44a66443aa9417ada7de1fd386e0f6c.tar.gz
bot-436d610ff44a66443aa9417ada7de1fd386e0f6c.tar.bz2
bot-436d610ff44a66443aa9417ada7de1fd386e0f6c.zip
Making the PING-loop optional
-rwxr-xr-xmodules/startup.py56
-rwxr-xr-xmodules/translate.py2
2 files changed, 29 insertions, 29 deletions
diff --git a/modules/startup.py b/modules/startup.py
index e650170..48c5fc9 100755
--- a/modules/startup.py
+++ b/modules/startup.py
@@ -18,39 +18,39 @@ def setup(phenny):
try: refresh_delay = float(phenny.config.refresh_delay)
except: pass
- def close():
- print "Nobody PONGed our PING, restarting"
- phenny.handle_close()
+ def close():
+ print "Nobody PONGed our PING, restarting"
+ phenny.handle_close()
- def pingloop():
- timer = threading.Timer(refresh_delay, close, ())
- phenny.data['startup.setup.timer'] = timer
- phenny.data['startup.setup.timer'].start()
- # print "PING!"
- phenny.write(('PING', phenny.config.host))
- phenny.data['startup.setup.pingloop'] = pingloop
+ def pingloop():
+ timer = threading.Timer(refresh_delay, close, ())
+ phenny.data['startup.setup.timer'] = timer
+ phenny.data['startup.setup.timer'].start()
+ # print "PING!"
+ phenny.write(('PING', phenny.config.host))
+ phenny.data['startup.setup.pingloop'] = pingloop
- def pong(phenny, input):
- try:
- # print "PONG!"
- phenny.data['startup.setup.timer'].cancel()
- time.sleep(refresh_delay + 60.0)
- pingloop()
- except: pass
- pong.event = 'PONG'
- pong.thread = True
- pong.rule = r'.*'
- phenny.variables['pong'] = pong
+ def pong(phenny, input):
+ try:
+ # print "PONG!"
+ phenny.data['startup.setup.timer'].cancel()
+ time.sleep(refresh_delay + 60.0)
+ pingloop()
+ except: pass
+ pong.event = 'PONG'
+ pong.thread = True
+ pong.rule = r'.*'
+ phenny.variables['pong'] = pong
- # Need to wrap handle_connect to start the loop.
- inner_handle_connect = phenny.handle_connect
+ # Need to wrap handle_connect to start the loop.
+ inner_handle_connect = phenny.handle_connect
- def outer_handle_connect():
- inner_handle_connect()
- if phenny.data.get('startup.setup.pingloop'):
- phenny.data['startup.setup.pingloop']()
+ def outer_handle_connect():
+ inner_handle_connect()
+ if phenny.data.get('startup.setup.pingloop'):
+ phenny.data['startup.setup.pingloop']()
- phenny.handle_connect = outer_handle_connect
+ phenny.handle_connect = outer_handle_connect
def startup(phenny, input):
if hasattr(phenny.config, 'serverpass'):
diff --git a/modules/translate.py b/modules/translate.py
index ec59db0..94e5f64 100755
--- a/modules/translate.py
+++ b/modules/translate.py
@@ -90,7 +90,7 @@ def tr2(phenny, input):
command = cmd
phrase = command
- if (len(phrase) > 350) and (not context.admin):
+ if (len(phrase) > 350) and (not input.admin):
return phenny.reply('Phrase must be under 350 characters.')
src, dest = args