Skip to content

Commit

Permalink
core: Homogenize login configs
Browse files Browse the repository at this point in the history
Per #716, old sundry configs will be removed in 6.0
  • Loading branch information
embolalia committed Mar 11, 2015
1 parent 4cadc92 commit db55dab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
43 changes: 23 additions & 20 deletions willie/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@
LOGGER = get_logger(__name__)


def auth_after_register(bot):
"""Do NickServ/AuthServ auth"""
if bot.config.core.auth_method == 'nickserv' or bot.config.core.nickserv_password:
nickserv_name = bot.config.core.auth_target or bot.config.core.nickserv_name or 'NickServ'
bot.msg(
nickserv_name,
'IDENTIFY %s' % bot.config.core.nickserv_password
)

elif bot.config.core.auth_method == 'authserv' or bot.config.core.authserv_password:
account = bot.config.core.auth_username or bot.config.core.authserv_account
password = bot.config.core.auth_password or bot.config.core.authserv_password
bot.write((
'AUTHSERV auth',
account + ' ' + password
))


@willie.module.event('001', '251')
@willie.module.rule('.*')
@willie.module.thread(False)
Expand All @@ -46,20 +64,7 @@ def startup(bot, trigger):

bot.connection_registered = True

if bot.config.core.nickserv_password is not None:
nickserv_name = bot.config.core.nickserv_name or 'NickServ'
bot.msg(
nickserv_name,
'IDENTIFY %s' % bot.config.core.nickserv_password
)

#Use Authserv if authserv_password and authserv_account is set in config.
if (bot.config.core.authserv_password is not None
and bot.config.core.authserv_account is not None):
bot.write((
'AUTHSERV auth',
bot.config.core.authserv_account + ' ' + bot.config.authserv_password
))
auth_after_register(bot)

#Set bot modes per config, +B if no config option is defined
if bot.config.has_option('core', 'modes'):
Expand Down Expand Up @@ -375,7 +380,7 @@ def recieve_cap_ls_reply(bot, trigger):

# If we want to do SASL, we have to wait before we can send CAP END. So if
# we are, wait on 903 (SASL successful) to send it.
if bot.config.core.sasl_password:
if bot.config.core.auth_method == 'sasl' or bot.config.core.sasl_password:
bot.write(('CAP', 'REQ', 'sasl'))
else:
bot.write(('CAP', 'END'))
Expand All @@ -384,7 +389,8 @@ def recieve_cap_ls_reply(bot, trigger):
def recieve_cap_ack_sasl(bot):
# Presumably we're only here if we said we actually *want* sasl, but still
# check anyway.
if not bot.config.core.sasl_password:
password = bot.config.core.auth_password or bot.config.core.sasl_password
if not password:
return
mech = bot.config.core.sasl_mechanism or 'PLAIN'
bot.write(('AUTHENTICATE', mech))
Expand All @@ -397,10 +403,7 @@ def auth_proceed(bot, trigger):
# How did we get here? I am not good with computer.
return
# Is this right?
if bot.config.core.sasl_username:
sasl_username = bot.config.core.sasl_username
else:
sasl_username = bot.nick
sasl_username = bot.config.core.auth_username or bot.config.core.sasl_username or bot.nick
sasl_token = '\0'.join((sasl_username, sasl_username,
bot.config.core.sasl_password))
# Spec says we do a base 64 encode on the SASL stuff
Expand Down
5 changes: 3 additions & 2 deletions willie/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ def handle_connect(self):
# 421 Unknown command, which we'll ignore
self.write(('CAP', 'LS'))

if self.config.core.server_password is not None:
self.write(('PASS', self.config.core.server_password))
if self.config.core.auth_method == 'server' or self.config.core.server_password:
password = self.config.core.auth_password or self.config.core.server_password
self.write(('PASS', password))
self.write(('NICK', self.nick))
self.write(('USER', self.user, '+iw', self.nick), self.name)

Expand Down
1 change: 0 additions & 1 deletion willie/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def add_attribute(function):
if not hasattr(function, "intents"):
function.intents = []
function.intents.extend(intent_list)
print function.intents
return function
return add_attribute

Expand Down

0 comments on commit db55dab

Please sign in to comment.