596
596
class Factos(callbacks.Plugin):
597
597
"""See README.txt for detailed info of how to use this plugin."""
598
598
flags = (re.IGNORECASE | re.VERBOSE)
599
addressedRegexps = ('ignore', 'getFact', 'tellFact', 'addFact', 'editFact', 'addAlias',
600
'substitute', 'substitute2', 'appendFact')
599
addressedRegexps = ('ignore',
600
'tellFact', 'appendFact',
601
'substitute', 'substitute2',
602
'addFact', 'editFact', 'addAlias',
602
606
def __init__(self, irc):
603
607
self.__parent = super(Factos, self)
604
608
self.__parent.__init__(irc)
605
609
# compile regexps
606
610
self.addressedRes = []
612
reFact_ns = Fact.regexp.replace('\s', '')
607
613
for name in self.addressedRegexps:
608
614
method = getattr(self, name)
609
s = method.__doc__.replace(':fact:', Fact.regexp)
617
s = s.replace(':fact:', reFact)
619
s = s.replace(':fact_ns:', reFact_ns)
620
#log.debug('regexp %s, %r' %(name, s))
610
621
r = re.compile(s, self.flags)
611
622
self.addressedRes.append((r, name))
902
913
def editFact(self, irc, msg, channel, match):
904
no[\s,]\s? # must start with 'no,' or 'no '
905
(.+) # anything (for check against addFact or addAlias regexps)
915
no,\s? # must start with 'no,'
916
(.+) # anything (for check against addFact or addAlias regexps)
908
919
edit = match.groups()[0]
1018
1029
appendFactOpts = ('preview', )
1020
1031
def appendFact(self, irc, msg, channel, match):
1021
r"""(?:añadir|añade|agregar?)\sa\s # start with 'añadir a' or other variation
1022
(:fact:) # fact name
1023
\s(.+) # text to append
1032
r"""(?:añadir|añade|agregar?)\sa\s # start with 'añadir a' or other variation
1033
(?:(:fact:), # fact name with spaces
1034
|(:fact_ns:)\s) # fact name without spaces
1035
\s?(.+) # text to append
1026
name, data = match.groups()
1038
name1, name2, data = match.groups()
1039
name = name1 or name2
1027
1040
name, localChannel = Fact.stripChannel(name)
1028
1041
fact = self.Fact(name=name, channel=localChannel)
1029
1042
logInfo(irc, msg, 'appendFact called by $hostmask at $channel. append:\'%s\''