Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
wantzel
Commits
cf58eb92
Commit
cf58eb92
authored
Jul 05, 2016
by
Mindiell
Browse files
Issue #8: Wanzel surveille désormais le wiki de LQdN et signale les modifications sur #lqdn-travail
parent
7fce3f9b
Pipeline
#40
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
messages.py
View file @
cf58eb92
...
...
@@ -106,4 +106,7 @@ messages = {
"deoped"
:
"""Vilain %s )o;"""
,
"wiki_update"
:
"""%s a mis à jour la page "%s" sur le wiki (%s)"""
,
}
wantzel.py
View file @
cf58eb92
...
...
@@ -149,7 +149,7 @@ class Wantzel(object):
Initialization of bot over IRC.
"""
self
.
number
=
None
# default last_entry_published
# default last_entry_published
for tweets
self
.
last_entry_published
=
time
.
strptime
(
"2000-01-01"
,
"%Y-%m-%d"
)
# See if there is something in the db
connection
=
sqlite3
.
connect
(
config
.
sqlite_db
)
...
...
@@ -159,6 +159,17 @@ class Wantzel(object):
"%Y-%m-%d %H:%M:%S %Z"
)
Utils
.
debug
(
"Dernier tweet: %s"
%
self
.
last_entry_published
)
# default last_entry_published for wiki
self
.
last_entry_updated
=
time
.
strptime
(
"2000-01-01"
,
"%Y-%m-%d"
)
# See if there is something in the db
connection
=
sqlite3
.
connect
(
config
.
sqlite_db
)
for
row
in
connection
.
execute
(
"SELECT last_entry_updated FROM wikis"
):
self
.
last_entry_updated
=
time
.
strptime
(
row
[
0
].
encode
(
"utf-8"
),
"%Y-%m-%d %H:%M:%S %Z"
)
Utils
.
debug
(
"Dernière mise à jour du wiki: %s"
%
self
.
last_entry_updated
)
self
.
irc
=
IrcClientFactory
(
config
)
self
.
irc
.
set_privmsg
=
self
.
set_privmsg
reactor
.
connectTCP
(
config
.
server
,
config
.
port
,
self
.
irc
)
...
...
@@ -174,6 +185,7 @@ class Wantzel(object):
self
.
rp_to_twitter
(
"http://www.laquadrature.net/en/press-review/feed"
)
self
.
count_articles
()
self
.
op_verification
()
self
.
wiki_updates
()
# Recalling the timer
reactor
.
callLater
(
config
.
timer
,
self
.
timer
)
...
...
@@ -654,6 +666,39 @@ class Wantzel(object):
Utils
.
debug
(
entry
.
title
)
Utils
.
debug
(
entry
.
published_parsed
)
def
wiki_updates
(
self
):
url
=
"https://wiki.laquadrature.net/api.php?days=1&limit=50&translations=filter&action=feedrecentchanges&feedformat=atom"
now
=
time
.
localtime
()
today
=
time
.
strptime
(
"%s-%s-%s %s"
%
(
now
.
tm_year
,
now
.
tm_mon
,
now
.
tm_mday
,
time
.
tzname
[
0
]
),
"%Y-%m-%d %Z"
)
entries
=
feedparser
.
parse
(
url
)[
'entries'
]
for
entry
in
entries
:
# if date of update is greater than today midnight
if
today
<
entry
.
updated_parsed
:
if
self
.
last_entry_updated
<
entry
.
updated_parsed
:
# Ecriture de la mise à jour sur le canal de travail
self
.
send_message
(
"#mytipy"
,
messages
[
"wiki_update"
]
%
(
entry
.
author
.
encode
(
"utf-8"
),
entry
.
title
.
encode
(
"utf-8"
),
entry
.
link
.
encode
(
"utf-8"
),
))
# Save last_entry_published
self
.
last_entry_updated
=
entry
.
updated_parsed
last_entry_updated
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S %Z"
,
self
.
last_entry_updated
)
connection
=
sqlite3
.
connect
(
config
.
sqlite_db
)
connection
.
execute
(
"UPDATE wikis SET last_entry_updated=?"
,
(
last_entry_updated
,)
)
connection
.
commit
()
if
__name__
==
'__main__'
:
Wantzel
()
...
...
Write
Preview
Supports
Markdown
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