mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Added re command.
This commit is contained in:
parent
e5c58089ce
commit
62c407d694
@ -39,6 +39,8 @@ Commands include:
|
|||||||
|
|
||||||
from baseplugin import *
|
from baseplugin import *
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
@ -72,6 +74,19 @@ class Utilities(callbacks.Privmsg):
|
|||||||
i = int(i)
|
i = int(i)
|
||||||
args = callbacks.tokenize(rest)
|
args = callbacks.tokenize(rest)
|
||||||
irc.reply(msg, args[i])
|
irc.reply(msg, args[i])
|
||||||
|
|
||||||
|
def re(self, irc, msg, args):
|
||||||
|
"""<regexp> <text>
|
||||||
|
|
||||||
|
Returns all matches to <regexp> (in the form /regexp/flags) in text.
|
||||||
|
"""
|
||||||
|
(re, text) = privmsgs.getArgs(args, needed=2)
|
||||||
|
(_, re, flags) = re.split('/')
|
||||||
|
flag = 0
|
||||||
|
for c in flags:
|
||||||
|
flag &= getattr(re, c.upper())
|
||||||
|
r = re.compile(re, flag)
|
||||||
|
irc.reply(msg, ' '.join(r.findall(text)))
|
||||||
|
|
||||||
|
|
||||||
Class = Utilities
|
Class = Utilities
|
||||||
|
Loading…
Reference in New Issue
Block a user