-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdykCheck.py
41 lines (34 loc) · 1.07 KB
/
dykCheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pywikibot
from datetime import date, timedelta
site = pywikibot.Site("lv", "wikipedia")
site.login()
site.get_tokens('edit')
def doAPI(datestr):
r = pywikibot.data.api.Request(
site=site,
action="expandtemplates",
format="json",
text='{{Vai tu zināji/Sagatave|' + datestr + '}}',
prop='wikitext'
).submit()
outputstr = r['expandtemplates']['wikitext']
return outputstr
message = """{{ping|Biafra|Edgars2007|Papuass|ScAvenger}} lapā "[[Veidne:Vai tu zināji/Sagatave]]" nav pievienoti fakti rītdienai! Lūdzu pievienojiet. --~~~~"""
def putNotif(day_name):
r = pywikibot.data.api.Request(
site=site,
action='edit',
format='json',
title='Vikipēdija:Administratoru ziņojumu dēlis',
section='new',
sectiontitle='Nav faktu rītdienai ({})'.format(day_name),
text=message,
token=site.tokens['edit'],
summary='Nav faktu rītdienai'
).submit()
yesterday = date.today() + timedelta(1)
nextday = yesterday.strftime('%Y-%m-%d')
newot = doAPI(nextday)
newot = newot.strip()
if newot == '':
putNotif(nextday)