RelayNext: make options configurable

This commit is contained in:
James Lu 2015-01-04 16:27:37 -08:00
parent 3419de9127
commit 169c1873dc
2 changed files with 20 additions and 9 deletions

View File

@ -36,7 +36,8 @@ try:
except: except:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
_ = lambda x:x _ = lambda x: x
def configure(advanced): def configure(advanced):
# This will be called by supybot to configure this module. advanced is # This will be called by supybot to configure this module. advanced is
@ -48,9 +49,17 @@ def configure(advanced):
RelayNext = conf.registerPlugin('RelayNext') RelayNext = conf.registerPlugin('RelayNext')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(RelayNext, 'someConfigVariableName', conf.registerChannelValue(RelayNext, 'color',
# registry.Boolean(False, _("""Help for someConfigVariableName."""))) registry.Boolean(True, _("""Determines whether the bot will color relayed
PRIVMSGs so as to make the messages easier to read.""")))
conf.registerChannelValue(RelayNext, 'hostmasks',
registry.Boolean(True, _("""Determines whether the bot will relay the
hostmask of the person joining or parting the channel when he or she joins
or parts.""")))
conf.registerChannelValue(RelayNext, 'noHighlight',
registry.Boolean(False, _("""Determines whether the bot should prefix nicks
with a hyphen (-) to prevent excess highlights (in PRIVMSGs and actions).""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -46,7 +46,8 @@ try:
except ImportError: except ImportError:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
_ = lambda x:x _ = lambda x: x
filename = conf.supybot.directories.data.dirize("RelayNext.db") filename = conf.supybot.directories.data.dirize("RelayNext.db")
@ -69,7 +70,8 @@ class RelayNext(callbacks.Plugin):
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
pickle.dump(self.db, f, 2) pickle.dump(self.db, f, 2)
except Exception as e: except Exception as e:
self.log.warning('RelayNext: Unable to write pickled database: %s', e) self.log.warning('RelayNext: Unable to write pickled database: %s',
e)
def __init__(self, irc): def __init__(self, irc):
self.__parent = super(RelayNext, self) self.__parent = super(RelayNext, self)
@ -145,10 +147,10 @@ class RelayNext(callbacks.Plugin):
s = '' s = ''
nick = msg.nick nick = msg.nick
userhost = '' userhost = ''
noHighlight = True
useHostmask = True
color = True
channel = msg.args[0] channel = msg.args[0]
noHighlight = self.registryValue('noHighlight', channel)
useHostmask = self.registryValue('hostmasks', channel)
color = self.registryValue('color', channel)
netname = irc.network.lower() netname = irc.network.lower()
if color: if color: