RelayNext: Optionally show status prefixes in messages (Closes #38)

This commit is contained in:
James Lu 2016-02-11 10:02:45 -08:00
parent 867e61ea78
commit 52f0fb2d46
2 changed files with 16 additions and 1 deletions

View File

@ -60,6 +60,9 @@ conf.registerChannelValue(RelayNext, 'hostmasks',
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).""")))
conf.registerChannelValue(RelayNext, 'showPrefixes',
registry.Boolean(False, _("""Determines whether the bot should status prefixes
(@, %, +) when relaying.""")))
conf.registerGroup(RelayNext, 'antiflood')
conf.registerChannelValue(RelayNext.antiflood, 'enable',

View File

@ -115,7 +115,7 @@ class RelayNext(callbacks.Plugin):
Formats a relay given the IRC object, msg object, and channel.
"""
s = ''
nick = msg.nick
nick = real_nick = msg.nick
userhost = ''
noHighlight = self.registryValue('noHighlight', channel)
useHostmask = self.registryValue('hostmasks', channel)
@ -151,6 +151,18 @@ class RelayNext(callbacks.Plugin):
elif msg.command == 'PRIVMSG':
text = msg.args[1]
# Show status prefixes (@%+) in front of the nick if enabled,
# but only the highest prefix.
if self.registryValue("showPrefixes", channel):
chobj = irc.state.channels[channel]
if chobj.isOp(real_nick):
nick = '@' + nick
elif chobj.isHalfop(real_nick):
nick = '%' + nick
elif chobj.isVoice(real_nick):
nick = '+' + nick
if re.match('^\x01ACTION .*\x01$', text):
text = text[8:-1]
s = '* %s %s' % (nick, text)