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
W
wantzel
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
Brendan Abolivier
wantzel
Commits
cf58eb92
Commit
cf58eb92
authored
Jul 05, 2016
by
Mindiell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#8
: Wanzel surveille désormais le wiki de LQdN et signale les modifications sur #lqdn-travail
parent
7fce3f9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
messages.py
messages.py
+3
-0
wantzel.py
wantzel.py
+46
-1
No files found.
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
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