Skip to content

Commit 19066b6

Browse files
committed
AutoMode: Add 'auto*' capabilities to override the configuration values (which apply to capabilities also used elsewhere).
1 parent 3c7f9d0 commit 19066b6

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

plugins/AutoMode/plugin.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,35 @@ def doJoin(self, irc, msg):
5454
fallthrough = self.registryValue('fallthrough', channel)
5555
def do(type):
5656
cap = ircdb.makeChannelCapability(channel, type)
57+
cap_auto = ircdb.makeChannelCapability(channel, 'auto'+type)
5758
try:
58-
if ircdb.checkCapability(msg.prefix, cap,
59-
ignoreOwner=not self.registryValue('owner')):
60-
if self.registryValue(type, channel):
61-
self.log.info('Scheduling auto-%s of %s in %s.',
62-
type, msg.prefix, channel)
63-
def dismiss():
64-
"""Determines whether or not a mode has already
65-
been applied."""
66-
l = getattr(irc.state.channels[channel], type+'s')
67-
return (msg.nick in l)
68-
msgmaker = getattr(ircmsgs, type)
69-
schedule_msg(msgmaker(channel, msg.nick),
70-
dismiss)
71-
raise Continue # Even if fallthrough, let's only do one.
72-
elif not fallthrough:
73-
self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s'
74-
' is not enabled in %s, refusing to fall '
75-
'through.', msg.prefix, cap, type, channel)
76-
raise Continue
59+
apply_mode = ircdb.checkCapability(msg.prefix, cap,
60+
ignoreOwner=not self.registryValue('owner'))
7761
except KeyError:
78-
pass
62+
apply_mode = False
63+
try:
64+
override = ircdb.checkCapability(msg.prefix, cap_auto,
65+
ignoreOwner=not self.registryValue('owner'))
66+
except KeyError:
67+
override = False
68+
if apply_mode or override:
69+
if override or self.registryValue(type, channel):
70+
self.log.info('Scheduling auto-%s of %s in %s.',
71+
type, msg.prefix, channel)
72+
def dismiss():
73+
"""Determines whether or not a mode has already
74+
been applied."""
75+
l = getattr(irc.state.channels[channel], type+'s')
76+
return (msg.nick in l)
77+
msgmaker = getattr(ircmsgs, type)
78+
schedule_msg(msgmaker(channel, msg.nick),
79+
dismiss)
80+
raise Continue # Even if fallthrough, let's only do one.
81+
elif not fallthrough:
82+
self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s'
83+
' is not enabled in %s, refusing to fall '
84+
'through.', msg.prefix, cap, type, channel)
85+
raise Continue
7986
def schedule_msg(msg, dismiss):
8087
def f():
8188
if not dismiss():

0 commit comments

Comments
 (0)