mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
parent
8727e620ad
commit
f6f46f6689
@ -78,7 +78,8 @@ def addressed(nick, msg):
|
|||||||
return msg.args[1][1:].strip()
|
return msg.args[1][1:].strip()
|
||||||
else:
|
else:
|
||||||
return msg.args[1].strip()
|
return msg.args[1].strip()
|
||||||
elif ircutils.toLower(msg.args[1]).startswith(nick):
|
elif conf.replyWhenAddressedByNick and \
|
||||||
|
ircutils.toLower(msg.args[1]).startswith(nick):
|
||||||
try:
|
try:
|
||||||
(maybeNick, rest) = msg.args[1].split(None, 1)
|
(maybeNick, rest) = msg.args[1].split(None, 1)
|
||||||
while not ircutils.isNick(maybeNick):
|
while not ircutils.isNick(maybeNick):
|
||||||
@ -272,6 +273,22 @@ def formatArgumentError(method, name=None):
|
|||||||
else:
|
else:
|
||||||
return 'Invalid arguments for %s.' % method.__name__
|
return 'Invalid arguments for %s.' % method.__name__
|
||||||
|
|
||||||
|
def checkCommandCapability(msg, command):
|
||||||
|
anticap = ircdb.makeAntiCapability(command)
|
||||||
|
if ircdb.checkCapability(msg.prefix, anticap):
|
||||||
|
log.info('Preventing because of anticap: %s', msg.prefix)
|
||||||
|
return False
|
||||||
|
if ircutils.isChannel(msg.args[0]):
|
||||||
|
channel = msg.args[0]
|
||||||
|
antichancap = ircdb.makeChannelCapability(channel, anticap)
|
||||||
|
if ircdb.checkCapability(msg.prefix, antichancap):
|
||||||
|
log.info('Preventing because of antichancap: %s', msg.prefix)
|
||||||
|
return False
|
||||||
|
return conf.defaultAllow or \
|
||||||
|
ircdb.checkCapability(msg.prefix, command) or \
|
||||||
|
ircdb.checkCapability(msg.prefix, chancap)
|
||||||
|
|
||||||
|
|
||||||
class IrcObjectProxy:
|
class IrcObjectProxy:
|
||||||
"A proxy object to allow proper nested of commands (even threaded ones)."
|
"A proxy object to allow proper nested of commands (even threaded ones)."
|
||||||
def __init__(self, irc, msg, args):
|
def __init__(self, irc, msg, args):
|
||||||
@ -285,7 +302,7 @@ class IrcObjectProxy:
|
|||||||
self.notice = False
|
self.notice = False
|
||||||
self.private = False
|
self.private = False
|
||||||
self.finished = False
|
self.finished = False
|
||||||
self.prefixName = True
|
self.prefixName = conf.replyWithNickPrefix
|
||||||
self.noLengthCheck = False
|
self.noLengthCheck = False
|
||||||
if not args:
|
if not args:
|
||||||
self.finalEvaled = True
|
self.finalEvaled = True
|
||||||
@ -345,25 +362,9 @@ class IrcObjectProxy:
|
|||||||
else:
|
else:
|
||||||
del self.args[0]
|
del self.args[0]
|
||||||
cb = cbs[0]
|
cb = cbs[0]
|
||||||
anticap = ircdb.makeAntiCapability(name)
|
if not checkCommandCapability(self.msg, name):
|
||||||
log.printf('Checking for %s' % anticap)
|
self.error(self.msg, conf.replyNoCapability % name)
|
||||||
if ircdb.checkCapability(self.msg.prefix, anticap):
|
|
||||||
log.printf('Being prevented with anticap')
|
|
||||||
log.info('Preventing %s from calling %s' %
|
|
||||||
(self.msg.nick, name))
|
|
||||||
s = conf.replyNoCapability % name
|
|
||||||
self.error(self.msg, s, private=True)
|
|
||||||
return
|
return
|
||||||
recipient = self.msg.args[0]
|
|
||||||
if ircutils.isChannel(recipient):
|
|
||||||
chancap = ircdb.makeChannelCapability(recipient, anticap)
|
|
||||||
if ircdb.checkCapability(self.msg.prefix, chancap):
|
|
||||||
log.printf('Being prevented with chancap')
|
|
||||||
log.info('Preventing %s from calling %s' %
|
|
||||||
(self.msg.nick, name))
|
|
||||||
s = conf.replyNoCapability % name
|
|
||||||
self.error(self.msg, s, private=True)
|
|
||||||
return
|
|
||||||
command = getattr(cb, name)
|
command = getattr(cb, name)
|
||||||
Privmsg.handled = True
|
Privmsg.handled = True
|
||||||
if cb.threaded:
|
if cb.threaded:
|
||||||
@ -580,6 +581,9 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
if name == canonicalName(self.name()):
|
if name == canonicalName(self.name()):
|
||||||
handleBadArgs()
|
handleBadArgs()
|
||||||
elif self.isCommand(name):
|
elif self.isCommand(name):
|
||||||
|
if not checkCommandCapability(msg, name):
|
||||||
|
irc.error(msg, conf.replyNoCapability % name)
|
||||||
|
return
|
||||||
del args[0]
|
del args[0]
|
||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
try:
|
try:
|
||||||
|
16
src/conf.py
16
src/conf.py
@ -124,8 +124,22 @@ replyWhenNotCommand = True
|
|||||||
# replyWithPrivateNotice: True if replies to a user in a channel should be
|
# replyWithPrivateNotice: True if replies to a user in a channel should be
|
||||||
# noticed to that user instead of sent to the channel
|
# noticed to that user instead of sent to the channel
|
||||||
# itself.
|
# itself.
|
||||||
|
###
|
||||||
replyWithPrivateNotice = False
|
replyWithPrivateNotice = False
|
||||||
|
|
||||||
|
###
|
||||||
|
# replyWithNickPrefix: True if the bot should always prefix the nick of the
|
||||||
|
# person giving the command to its reply.
|
||||||
|
###
|
||||||
|
replyWithNickPrefix = True
|
||||||
|
|
||||||
|
###
|
||||||
|
# replyWhenAddressedByName: True if the bot should reply to messages of the
|
||||||
|
# form "botnick: foo" where "botnick" is the bot's
|
||||||
|
# nick.
|
||||||
|
###
|
||||||
|
replyWhenAddressedByName = True
|
||||||
|
|
||||||
###
|
###
|
||||||
# requireRegistration: Oftentimes a plugin will want to record who added or
|
# requireRegistration: Oftentimes a plugin will want to record who added or
|
||||||
# changed or messed with it last. Supybot's user database
|
# changed or messed with it last. Supybot's user database
|
||||||
@ -307,6 +321,8 @@ types = {
|
|||||||
#'allowEval': mybool,
|
#'allowEval': mybool,
|
||||||
'replyWhenNotCommand': mybool,
|
'replyWhenNotCommand': mybool,
|
||||||
'replyWithPrivateNotice': mybool,
|
'replyWithPrivateNotice': mybool,
|
||||||
|
'replyWithNickPrefix': mybool,
|
||||||
|
'replyWhenAddressedByName': mybool,
|
||||||
'requireRegistration': mybool,
|
'requireRegistration': mybool,
|
||||||
'enablePipeSyntax': mybool,
|
'enablePipeSyntax': mybool,
|
||||||
'replyError': mystr,
|
'replyError': mystr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user