Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F34912070
raw-paste-data.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
Urbanecm_WMF
Jan 9 2022, 11:58 AM
2022-01-09 11:58:29 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw-paste-data.txt
View Options
#!/usr/bin/env python3
import requests
import random
import time
API_URL = 'https://ar.wikipedia.org/w/api.php'
USERNAME = 'Martin Urbanec (WMF)'
PASSWORD = '' # password from Special:BotPasswords
MENTORS = ["جار الله","محمد أحمد عبد الفتاح","صالح","أحمد ناجي","Dr-Taher","Avicenno","Glory20","فيصل","Nehaoua","بندر","فاطمة الزهراء","Dyolf77","Dr. Mohammed","سيف القوضي"]
REASON = 'مرشدك السابق غير متوفر حاليا. قمنا بتعيين مرشد جديد لك!'
s = requests.Session()
s.headers.update({
'User-Agent': 'Reassign mentors (murbanec-ctr@wikimedia.org)'
})
def make_request(payload):
payload['format'] = 'json'
return s.post(API_URL, data=payload)
def get_token(type='csrf'):
r = make_request({
'action': 'query',
'meta': 'tokens',
'type': type
})
data = r.json()
return data.get('query', {}).get('tokens', {}).get('%stoken' % type)
r = make_request({
"action": "login",
"lgname": USERNAME,
"lgpassword": PASSWORD,
"lgtoken": get_token('login')
})
print(r.json())
mentees = open('mentees.txt').read().split('\n')
token = get_token()
mentees.pop()
for mentee in mentees:
mentor = random.choice(MENTORS)
print("Setting %s's mentor to %s" % (mentee, mentor))
print(make_request({
"action": "growthsetmentor",
"mentee": mentee,
"mentor": mentor,
"reason": REASON,
"token": token
}).json())
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9321391
Default Alt Text
raw-paste-data.txt (1 KB)
Attached To
Mode
P14136 (An Untitled Masterwork)
Attached
Detach File
Event Timeline
Log In to Comment