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

@ -38,6 +38,7 @@ except:
# without the i18n module
_ = lambda x: x
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified themself as an advanced
@ -48,9 +49,17 @@ def configure(advanced):
RelayNext = conf.registerPlugin('RelayNext')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(RelayNext, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(RelayNext, 'color',
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:

View File

@ -48,6 +48,7 @@ except ImportError:
# without the i18n module
_ = lambda x: x
filename = conf.supybot.directories.data.dirize("RelayNext.db")
class RelayNext(callbacks.Plugin):
@ -69,7 +70,8 @@ class RelayNext(callbacks.Plugin):
with open(filename, 'wb') as f:
pickle.dump(self.db, f, 2)
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):
self.__parent = super(RelayNext, self)
@ -145,10 +147,10 @@ class RelayNext(callbacks.Plugin):
s = ''
nick = msg.nick
userhost = ''
noHighlight = True
useHostmask = True
color = True
channel = msg.args[0]
noHighlight = self.registryValue('noHighlight', channel)
useHostmask = self.registryValue('hostmasks', channel)
color = self.registryValue('color', channel)
netname = irc.network.lower()
if color: