2010-04-14 02:57:52 +00:00
|
|
|
import re
|
2010-01-17 04:24:36 +00:00
|
|
|
import socket
|
2010-04-14 02:57:52 +00:00
|
|
|
import subprocess
|
2010-03-11 23:34:54 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
from util import hook
|
2010-01-17 04:24:36 +00:00
|
|
|
|
2010-03-11 23:34:54 +00:00
|
|
|
socket.setdefaulttimeout(10) # global setting
|
2010-01-17 04:24:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
#autorejoin channels
|
|
|
|
@hook.event('KICK')
|
2010-03-12 00:28:17 +00:00
|
|
|
def rejoin(paraml, conn=None):
|
2010-02-02 04:42:34 +00:00
|
|
|
if paraml[1] == conn.nick:
|
|
|
|
if paraml[0].lower() in conn.channels:
|
|
|
|
conn.join(paraml[0])
|
2010-01-17 04:24:36 +00:00
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
#join channels when invited
|
|
|
|
@hook.event('INVITE')
|
2010-03-12 00:28:17 +00:00
|
|
|
def invite(paraml, conn=None):
|
|
|
|
conn.join(paraml[-1])
|
2010-01-17 04:24:36 +00:00
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
@hook.event('004')
|
2010-03-12 00:28:17 +00:00
|
|
|
def onjoin(paraml, conn=None):
|
2010-03-14 23:55:58 +00:00
|
|
|
# identify to services
|
2010-02-02 04:42:34 +00:00
|
|
|
nickserv_password = conn.conf.get('nickserv_password', '')
|
|
|
|
nickserv_name = conn.conf.get('nickserv_name', 'nickserv')
|
|
|
|
nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY %s')
|
2010-01-17 04:24:36 +00:00
|
|
|
if nickserv_password:
|
2010-02-02 04:42:34 +00:00
|
|
|
conn.msg(nickserv_name, nickserv_command % nickserv_password)
|
2010-03-11 23:34:54 +00:00
|
|
|
time.sleep(1)
|
2010-03-14 23:55:58 +00:00
|
|
|
|
|
|
|
# set mode on self
|
|
|
|
mode = conn.conf.get('mode')
|
|
|
|
if mode:
|
|
|
|
conn.cmd('MODE', [conn.nick, mode])
|
|
|
|
|
|
|
|
# join channels
|
2010-03-11 23:34:54 +00:00
|
|
|
for channel in conn.channels:
|
|
|
|
conn.join(channel)
|
2010-03-13 06:16:06 +00:00
|
|
|
time.sleep(1) # don't flood JOINs
|
2010-04-14 02:57:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
@hook.regex(r'^\x01VERSION\x01$')
|
|
|
|
def version(inp, notice=None):
|
2010-08-24 21:59:47 +00:00
|
|
|
p = subprocess.Popen(['git', 'log', '--oneline'], stdout=subprocess.PIPE)
|
2010-04-14 02:57:52 +00:00
|
|
|
stdout, _ = p.communicate()
|
|
|
|
p.wait()
|
2010-08-24 21:59:47 +00:00
|
|
|
|
|
|
|
revnumber = len(stdout.splitlines())
|
2010-04-14 02:57:52 +00:00
|
|
|
|
2010-08-24 21:59:47 +00:00
|
|
|
ret = stdout.split(None, 1)[0]
|
|
|
|
|
|
|
|
notice('\x01VERSION skybot %s r%d - http://github.com/rmmh/'
|
|
|
|
'skybot/\x01' % (ret, revnumber))
|