mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-04 08:34:11 +01:00
Made isCommand use canonicalName and added getCommand.
This commit is contained in:
parent
669ac8995f
commit
ef4bff5571
@ -453,7 +453,10 @@ class IrcObjectProxy:
|
|||||||
n = ircutils.bold('(%s)')
|
n = ircutils.bold('(%s)')
|
||||||
n %= utils.nItems('message', len(msgs), 'more')
|
n %= utils.nItems('message', len(msgs), 'more')
|
||||||
response = '%s %s' % (response, n)
|
response = '%s %s' % (response, n)
|
||||||
mask = msg.prefix.split('!', 1)[1]
|
prefix = msg.prefix
|
||||||
|
if self.to and ircutils.isNick(self.to):
|
||||||
|
prefix = self.getRealIrc().state.nickToHostmask(self.to)
|
||||||
|
mask = prefix.split('!', 1)[1]
|
||||||
Privmsg._mores[mask] = msgs
|
Privmsg._mores[mask] = msgs
|
||||||
private = self.private or not ircutils.isChannel(msg.args[0])
|
private = self.private or not ircutils.isChannel(msg.args[0])
|
||||||
Privmsg._mores[msg.nick] = (private, msgs)
|
Privmsg._mores[msg.nick] = (private, msgs)
|
||||||
@ -647,8 +650,10 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
self.__parent.__call__(irc, msg)
|
self.__parent.__call__(irc, msg)
|
||||||
|
|
||||||
def isCommand(self, methodName):
|
def isCommand(self, methodName):
|
||||||
|
"""Returns whether a given method name is a command in this plugin."""
|
||||||
# This function is ugly, but I don't want users to call methods like
|
# This function is ugly, but I don't want users to call methods like
|
||||||
# doPrivmsg or __init__ or whatever, and this is good to stop them.
|
# doPrivmsg or __init__ or whatever, and this is good to stop them.
|
||||||
|
methodName = canonicalName(methodName)
|
||||||
if hasattr(self, methodName):
|
if hasattr(self, methodName):
|
||||||
method = getattr(self, methodName)
|
method = getattr(self, methodName)
|
||||||
if inspect.ismethod(method):
|
if inspect.ismethod(method):
|
||||||
@ -659,6 +664,12 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def getCommand(self, methodName):
|
||||||
|
"""Gets the given command from this plugin."""
|
||||||
|
assert self.isCommand(methodName)
|
||||||
|
methodName = canonicalName(methodName)
|
||||||
|
return getattr(self, methodName)
|
||||||
|
|
||||||
def callCommand(self, f, irc, msg, *L):
|
def callCommand(self, f, irc, msg, *L):
|
||||||
name = f.im_func.func_name
|
name = f.im_func.func_name
|
||||||
assert L, 'Odd, nothing in L. This can\'t happen.'
|
assert L, 'Odd, nothing in L. This can\'t happen.'
|
||||||
|
Loading…
Reference in New Issue
Block a user