From 9d084e2e7035b44306b5534d1ca9e818f4c72827 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 8 May 2014 08:33:01 +0000 Subject: [PATCH] Allow network-specific username and ident. Closes GH-589. --- src/conf.py | 6 ++++++ src/irclib.py | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/conf.py b/src/conf.py index 5dd1801eb..b9baed236 100644 --- a/src/conf.py +++ b/src/conf.py @@ -315,6 +315,12 @@ def registerNetwork(name, password='', ssl=False, sasl_username='', registerGlobalValue(network, 'nick', ValidNickOrEmpty('', _("""Determines what nick the bot will use on this network. If empty, defaults to supybot.nick."""))) + registerGlobalValue(network, 'ident', ValidNickOrEmpty('', _("""Determines + the bot's ident string, if the server doesn't provide one by default. + If empty, defaults to supybot.ident."""))) + registerGlobalValue(network, 'user', registry.String('', _("""Determines + the username the bot sends to the server. If empty, defaults to + supybot.user"""))) registerGlobalValue(network, 'umodes', registry.String('', _("""Determines what user modes the bot will request from the server when it first connects. If empty, defaults to diff --git a/src/irclib.py b/src/irclib.py index 90c7b5c32..504f74c1b 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -895,12 +895,12 @@ class Irc(IrcCommandDispatcher): def _setNonResettingVariables(self): # Configuration stuff. - self.nick = conf.supybot.nick() - network_nick = conf.supybot.networks.get(self.network).nick() - if network_nick != '': - self.nick = network_nick - self.user = conf.supybot.user() - self.ident = conf.supybot.ident() + def get_value(name): + return getattr(conf.supybot.networks.get(self.network), name)() or \ + getattr(conf.supybot, name)() + self.nick = get_value('nick') + self.user = get_value('user') + self.ident = get_value('ident') self.alternateNicks = conf.supybot.nick.alternates()[:] self.password = conf.supybot.networks.get(self.network).password() self.sasl_username = \