Commit a2d75d1e authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

allow two syntax

parent 9ef04f27
......@@ -154,24 +154,36 @@ class MmBot(irc.IRCClient):
# coeur de metier
m = msg
reg = r'(?:'
reg+= r'\[(?P<codename1>[A-Za-z0-9]+) (?P<article1>[^ \]]+)\]'
reg+= r'|'
reg+= r'\[(?P<article2>[^ \]]+) du (?P<codename2>[A-Za-z0-9]+)\]'
reg+= r')'
while True:
a = re.match('.*?\[([A-Za-z0-9]+) ([^ \]]+)\]', m)
a = re.match('.*?%s'%reg, m)
if a is None:
break
codename = a.groups()[0]
codeid = a.groups()[1]
d=a.groupdict()
if not d['codename1'] is None:
codename = d['codename1']
article = d['article1']
form = '%s %s' % (codename, article)
if not d['codename2'] is None:
codename = d['codename2']
article = d['article2']
form = '%s du %s' % (article, codename)
trop_jeune = False
if self.view.has_key( (channel,codename,codeid) ):
if time.time()-self.view[(channel,codename,codeid)] < self.botconf['remain_time']:
if self.view.has_key( (channel,codename,article) ):
if time.time()-self.view[(channel,codename,article)] < self.botconf['remain_time']:
trop_jeune = True
if not trop_jeune:
link = self.codes.get(codename,codeid)
link = self.codes.get(codename,article)
if not link is None:
self.msg(channel,'[%s %s]: %s' % (codename, codeid, link))
self.view[(channel,codename,codeid)] = time.time()
m= re.sub('\[([A-Za-z0-9]+) ([^ \]]+)\]','',m,1)
self.msg(channel,'[%s]: %s' % (form, link))
self.view[(channel,codename,article)] = time.time()
m= re.sub(reg,'',m,1)
class MmBotFactory(protocol.ClientFactory):
......
......@@ -10,3 +10,4 @@ CD = LEGITEXT000006071307
CGI = LEGITEXT000006069577
CMF = LEGITEXT000006072026
CPCE = LEGITEXT000006070987
CRoute = LEGITEXT000006074228
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment