aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--reaktor/config.py6
-rwxr-xr-xreaktor/core.py19
-rw-r--r--reaktor/ircasy.py8
3 files changed, 24 insertions, 9 deletions
diff --git a/reaktor/config.py b/reaktor/config.py
index f5e8e06..dbe5ec3 100644
--- a/reaktor/config.py
+++ b/reaktor/config.py
@@ -24,6 +24,12 @@ irc_port = int(env.get('REAKTOR_PORT', 6667))
# TODO: do not implement functionality in the config :\
workdir = env.get('REAKTOR_STATEDIR', expanduser('~') + '/state')
irc_channels = env.get('REAKTOR_CHANNELS', '#krebs').split(',')
+try:
+ nickserv_password = open(
+ env.get('REAKTOR_NICKSERV_PASSWORD')
+ ).read().strip()
+except: # noqa: E722
+ nickserv_password = None
# static config
# if you want to change this part you have to copy the config
diff --git a/reaktor/core.py b/reaktor/core.py
index 7a2272c..fce49ff 100755
--- a/reaktor/core.py
+++ b/reaktor/core.py
@@ -37,14 +37,17 @@ class Reaktor(asybot):
self.getconf = getconf
log.info("using config file %s" % (config))
- asybot.__init__(self,
- getconf('irc_server'),
- getconf('irc_port'),
- getconf('irc_nickname'),
- getconf('irc_channels'),
- hammer_interval=getconf('irc_hammer_interval'),
- alarm_timeout=getconf('irc_alarm_timeout'),
- kill_timeout=getconf('irc_kill_timeout'))
+ asybot.__init__(
+ self,
+ getconf('irc_server'),
+ getconf('irc_port'),
+ getconf('irc_nickname'),
+ getconf('irc_channels'),
+ hammer_interval=getconf('irc_hammer_interval'),
+ alarm_timeout=getconf('irc_alarm_timeout'),
+ kill_timeout=getconf('irc_kill_timeout'),
+ nickserv_password=getconf('nickserv_password'),
+ )
def is_admin(self, prefix):
try:
diff --git a/reaktor/ircasy.py b/reaktor/ircasy.py
index f8f85d6..0a4d4eb 100644
--- a/reaktor/ircasy.py
+++ b/reaktor/ircasy.py
@@ -20,7 +20,7 @@ class asybot(asychat):
def __init__(
self, server, port, nickname, channels, realname=False, username=False,
hostname=False, hammer_interval=10, alarm_timeout=300,
- kill_timeout=360, loglevel=logging.ERROR
+ kill_timeout=360, loglevel=logging.ERROR, nickserv_password=None
):
asychat.__init__(self)
# logger magic
@@ -52,6 +52,7 @@ class asybot(asychat):
self.create_socket(AF_INET, SOCK_STREAM)
self.connect((self.server, self.port))
self.wrapper = TextWrapper(subsequent_indent=" ", width=400)
+ self.nickserv_password = nickserv_password
self.log.info('=> irc://%s@%s:%s/%s' %
(self.nickname, self.server, self.port, self.channels))
@@ -132,6 +133,9 @@ class asybot(asychat):
elif command == '376' or '422':
self.on_welcome(prefix, command, params, rest)
+ elif command == 'NOTICE' and rest.startswith('You are now identified'):
+ self.push('JOIN %s' % ','.join(self.channels))
+
self.reset_alarm()
def push(self, message):
@@ -177,6 +181,8 @@ class asybot(asychat):
self.PRIVMSG(target, ('ACTION ' + text + ''))
def on_welcome(self, prefix, command, params, rest):
+ if self.nickserv_password:
+ self.push(f'PRIVMSG nickserv :IDENTIFY {self.nickserv_password}')
self.push('JOIN %s' % ','.join(self.channels))
def on_kick(self, prefix, command, params, rest):