Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
legifrance-bot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
leger
legifrance-bot
Commits
a2d75d1e
Commit
a2d75d1e
authored
Aug 19, 2016
by
Jean-Benoist Leger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow two syntax
parent
9ef04f27
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
bot.py
bot.py
+21
-9
legifrance.conf
legifrance.conf
+1
-0
No files found.
bot.py
View file @
a2d75d1e
...
...
@@ -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
):
...
...
legifrance.conf
View file @
a2d75d1e
...
...
@@ -10,3 +10,4 @@ CD = LEGITEXT000006071307
CGI
=
LEGITEXT000006069577
CMF
=
LEGITEXT000006072026
CPCE
=
LEGITEXT000006070987
CRoute
=
LEGITEXT000006074228
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment