added configurable auto-invite-join
This commit is contained in:
parent
e6acc60343
commit
6cf588b994
|
@ -20,6 +20,7 @@ if not os.path.exists('config'):
|
||||||
"realname": "CloudBot - http://git.io/cloudbot",
|
"realname": "CloudBot - http://git.io/cloudbot",
|
||||||
"nickserv_password": "",
|
"nickserv_password": "",
|
||||||
"channels": ["#channel"],
|
"channels": ["#channel"],
|
||||||
|
"invitejoin": "True",
|
||||||
"autorejoin": "False",
|
"autorejoin": "False",
|
||||||
"command_prefix": ".",
|
"command_prefix": ".",
|
||||||
"stayalive": "",
|
"stayalive": "",
|
||||||
|
|
|
@ -7,6 +7,16 @@ from util import hook, http
|
||||||
|
|
||||||
socket.setdefaulttimeout(10)
|
socket.setdefaulttimeout(10)
|
||||||
|
|
||||||
|
# Auto-join on Invite (Configurable, defaults to True)
|
||||||
|
@hook.event('INVITE')
|
||||||
|
def invite(paraml, conn=None):
|
||||||
|
invitejoin = conn.conf.get('invitejoin', True)
|
||||||
|
if invitejoin:
|
||||||
|
conn.join(paraml[-1])
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Rejoin on kick (Configuragble, 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)
|
||||||
|
@ -14,11 +24,7 @@ def rejoin(paraml, conn=None):
|
||||||
conn.join(paraml[0])
|
conn.join(paraml[0])
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
# Identify to NickServ (or other service)
|
||||||
@hook.event('INVITE')
|
|
||||||
def invite(paraml, conn=None):
|
|
||||||
conn.join(paraml[-1])
|
|
||||||
|
|
||||||
@hook.event('004')
|
@hook.event('004')
|
||||||
def onjoin(paraml, conn=None, bot=None):
|
def onjoin(paraml, conn=None, bot=None):
|
||||||
nickserv_password = conn.conf.get('nickserv_password', '')
|
nickserv_password = conn.conf.get('nickserv_password', '')
|
||||||
|
@ -31,22 +37,25 @@ def onjoin(paraml, conn=None, bot=None):
|
||||||
bot.config['censored_strings'].append(nickserv_password)
|
bot.config['censored_strings'].append(nickserv_password)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
mode = conn.conf.get('mode')
|
mode = conn.conf.get('mode')
|
||||||
|
# Set bot modes
|
||||||
if mode:
|
if mode:
|
||||||
conn.cmd('MODE', [conn.nick, mode])
|
conn.cmd('MODE', [conn.nick, mode])
|
||||||
|
|
||||||
|
# Join config-defined channels
|
||||||
for channel in conn.channels:
|
for channel in conn.channels:
|
||||||
conn.join(channel)
|
conn.join(channel)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
# HTTP Useragent
|
||||||
http.ua_skybot = 'CloudBot - http://git.io/cloudbot'
|
http.ua_skybot = 'CloudBot - http://git.io/cloudbot'
|
||||||
|
|
||||||
|
# Stay-alive code
|
||||||
stayalive = conn.conf.get('stayalive')
|
stayalive = conn.conf.get('stayalive')
|
||||||
if stayalive:
|
if stayalive:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(conn.conf.get('stayalive_delay', 20))
|
time.sleep(conn.conf.get('stayalive_delay', 20))
|
||||||
conn.cmd('PING', [conn.nick])
|
conn.cmd('PING', [conn.nick])
|
||||||
|
# CTCPs
|
||||||
@hook.regex(r'^\x01VERSION\x01$')
|
@hook.regex(r'^\x01VERSION\x01$')
|
||||||
def ctcpversion(inp, notice=None):
|
def ctcpversion(inp, notice=None):
|
||||||
notice('\x01VERSION: CloudBot - http://git.io/cloudbot')
|
notice('\x01VERSION: CloudBot - http://git.io/cloudbot')
|
||||||
|
|
Reference in a new issue