fixed bug in stayalive code

This commit is contained in:
neersighted 2012-03-01 01:24:15 -08:00
parent 1789cd3b26
commit e061f4dd6d
2 changed files with 5 additions and 4 deletions

View file

@ -23,8 +23,8 @@ if not os.path.exists('config'):
"invitejoin": true, "invitejoin": true,
"autorejoin": false, "autorejoin": false,
"command_prefix": ".", "command_prefix": ".",
"stayalive": "", "stayalive": true,
"stayalive_delay": "20" "stayalive_delay": 20
} }
}, },
"disabled_plugins": [], "disabled_plugins": [],

View file

@ -18,7 +18,7 @@ def invite(paraml, conn=None):
return None return None
# Rejoin on kick (Configuragble, defaults to False) # Rejoin on kick (Configurable, defaults to False)
@hook.event('KICK') @hook.event('KICK')
def rejoin(paraml, conn=None): def rejoin(paraml, conn=None):
autorejoin = conn.conf.get('autorejoin', False) autorejoin = conn.conf.get('autorejoin', False)
@ -56,6 +56,7 @@ def onjoin(paraml, conn=None, bot=None):
# Stay-alive code # Stay-alive code
stayalive = conn.conf.get('stayalive') stayalive = conn.conf.get('stayalive')
if stayalive: if stayalive:
delay = conn.conf.get('stayalive_delay', 20)
while True: while True:
time.sleep(conn.conf.get('stayalive_delay', 20)) time.sleep(delay)
conn.cmd('PING', [conn.nick]) conn.cmd('PING', [conn.nick])