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
|
|
|
|
|
2011-03-29 13:48:44 +00:00
|
|
|
from util import hook, http
|
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
|
|
|
|
|
|
|
|
2011-03-29 13:48:44 +00:00
|
|
|
def get_version():
|
2014-11-26 23:58:28 +00:00
|
|
|
try:
|
|
|
|
stdout = subprocess.check_output(['git', 'log', '--format=%h'])
|
|
|
|
except:
|
|
|
|
revnumber = 0
|
|
|
|
shorthash = '????'
|
|
|
|
else:
|
|
|
|
revs = stdout.splitlines()
|
|
|
|
revnumber = len(revs)
|
|
|
|
shorthash = revs[0]
|
2011-05-20 06:13:11 +00:00
|
|
|
|
2011-05-11 20:40:04 +00:00
|
|
|
http.ua_skybot = 'Skybot/r%d %s (http://github.com/rmmh/skybot)' \
|
2014-01-14 21:12:37 +00:00
|
|
|
% (revnumber, shorthash)
|
2011-05-11 20:40:04 +00:00
|
|
|
|
|
|
|
return shorthash, revnumber
|
2011-03-29 13:48:44 +00:00
|
|
|
|
|
|
|
|
2014-01-14 21:12:37 +00:00
|
|
|
# autorejoin channels
|
2010-01-17 04:24:36 +00:00
|
|
|
@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:
|
2014-04-30 20:16:16 +00:00
|
|
|
if paraml[0].lower() in conn.conf.get("channels", []):
|
2010-02-02 04:42:34 +00:00
|
|
|
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
|
|
|
@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
|
2014-04-30 20:16:16 +00:00
|
|
|
for channel in conn.conf.get("channels", []):
|
2010-03-11 23:34:54 +00:00
|
|
|
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
|
|
|
|
2011-03-29 13:48:44 +00:00
|
|
|
# set user-agent
|
|
|
|
ident, rev = get_version()
|
2011-05-11 20:40:04 +00:00
|
|
|
|
2010-04-14 02:57:52 +00:00
|
|
|
|
|
|
|
@hook.regex(r'^\x01VERSION\x01$')
|
|
|
|
def version(inp, notice=None):
|
2011-03-29 13:48:44 +00:00
|
|
|
ident, rev = get_version()
|
2015-11-08 20:51:16 +00:00
|
|
|
notice('\x01VERSION h %s - https://git.xeserv.us/xena/h'
|
|
|
|
'\x01' % ident)
|