mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 22:51:01 +01:00
Removed premature optimization of using the regexp to decide when to tokenize. We'll optimize when we have to, likely by making tokenize memoize.
This commit is contained in:
parent
ef7cd08fdb
commit
8fc200ae1f
@ -274,7 +274,7 @@ def tokenize(s):
|
|||||||
args = Tokenizer(tokens).tokenize(s)
|
args = Tokenizer(tokens).tokenize(s)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
raise SyntaxError, str(e)
|
raise SyntaxError, str(e)
|
||||||
debug.msg('tokenize took %s seconds.' % (time.time() - start), 'verbose')
|
#debug.msg('tokenize took %s seconds.' % (time.time() - start), 'verbose')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def getCommands(tokens):
|
def getCommands(tokens):
|
||||||
@ -606,7 +606,6 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
funcname = '%s.%s' % (f.im_class.__name__, f.im_func.func_name)
|
funcname = '%s.%s' % (f.im_class.__name__, f.im_func.func_name)
|
||||||
debug.msg('%s took %s seconds' % (funcname, elapsed), 'verbose')
|
debug.msg('%s took %s seconds' % (funcname, elapsed), 'verbose')
|
||||||
|
|
||||||
_r = re.compile(r'^([^\s[]+)(?:\[|\s+|$)')
|
|
||||||
def doPrivmsg(self, irc, msg, rateLimit=True):
|
def doPrivmsg(self, irc, msg, rateLimit=True):
|
||||||
s = addressed(irc.nick, msg)
|
s = addressed(irc.nick, msg)
|
||||||
#debug.printf('Privmsg.doPrivmsg: s == %r' % s)
|
#debug.printf('Privmsg.doPrivmsg: s == %r' % s)
|
||||||
@ -615,22 +614,24 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
if ircdb.checkIgnored(msg.prefix, recipient):
|
if ircdb.checkIgnored(msg.prefix, recipient):
|
||||||
debug.msg('Privmsg.doPrivmsg: ignoring %s.' % msg.prefix)
|
debug.msg('Privmsg.doPrivmsg: ignoring %s.' % msg.prefix)
|
||||||
return
|
return
|
||||||
m = self._r.match(s)
|
try:
|
||||||
if m and self.isCommand(canonicalName(m.group(1))):
|
args = tokenize(s)
|
||||||
if rateLimit:
|
except SyntaxError, e:
|
||||||
self.rateLimiter.put(msg)
|
irc.queueMsg(reply(msg, debug.exnToString(e)))
|
||||||
msg = self.rateLimiter.get()
|
return
|
||||||
if msg:
|
if args and isinstance(args[0], str):
|
||||||
try:
|
args[0] = canonicalName(args[0])
|
||||||
args = tokenize(s)
|
if self.isCommand(args[0]):
|
||||||
|
if rateLimit:
|
||||||
|
self.rateLimiter.put(msg)
|
||||||
|
msg = self.rateLimiter.get()
|
||||||
|
if msg:
|
||||||
if conf.replyWhenNotCommand:
|
if conf.replyWhenNotCommand:
|
||||||
for command in getCommands(args):
|
for command in getCommands(args):
|
||||||
command = canonicalName(command)
|
command = canonicalName(command)
|
||||||
if not findCallbackForCommand(irc, command):
|
if not findCallbackForCommand(irc, command):
|
||||||
return
|
return
|
||||||
self.Proxy(irc, msg, args)
|
self.Proxy(irc, msg, args)
|
||||||
except SyntaxError, e:
|
|
||||||
irc.queueMsg(reply(msg, debug.exnToString(e)))
|
|
||||||
|
|
||||||
|
|
||||||
class IrcObjectProxyRegexp:
|
class IrcObjectProxyRegexp:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user