mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-10 12:59:22 +01:00
Added re command.
This commit is contained in:
parent
e5c58089ce
commit
62c407d694
@ -39,6 +39,8 @@ Commands include:
|
||||
|
||||
from baseplugin import *
|
||||
|
||||
import re
|
||||
|
||||
import privmsgs
|
||||
import callbacks
|
||||
|
||||
@ -73,6 +75,19 @@ class Utilities(callbacks.Privmsg):
|
||||
args = callbacks.tokenize(rest)
|
||||
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
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
Loading…
Reference in New Issue
Block a user