Melos has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/374051 )
Change subject: Show user rights expiry in user rights notification message
......................................................................
Show user rights expiry in user rights notification message
Bug: T164204
Change-Id: I572153dc5566378e55713dcb137f08828adeeb2a
---
M StewardBot/StewardBot.py
1 file changed, 38 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/tools/stewardbots
refs/changes/51/374051/1
diff --git a/StewardBot/StewardBot.py b/StewardBot/StewardBot.py
index aad2e29..50eb440 100644
--- a/StewardBot/StewardBot.py
+++ b/StewardBot/StewardBot.py
@@ -1073,6 +1073,43 @@
state1 = found.group('state1')
state2 = found.group('state2')
extra = found.group('extra')
+ #check expiry via api
+ urlapi =
("https://meta.wikimedia.org/w/api.php?action=query&format=json&list=logevents&letype=rights&letitle=User:"
+ usertarget + "&lelimit=1")
+ response = urllib.urlopen(urlapi)
+ data = json.loads(response.read())
+ oldright = data
['query']['logevents'][0]['params']['oldgroups']
+ newright = data
['query']['logevents'][0]['params']['newgroups']
+ lennewrights = len( newright ) + 1
+ lenoldrights = len( oldright ) + 1
+ chrightsn = ""
+ chrightso = ""
+ n= 1
+ o =1
+ while o < lenoldrights :
+ oldrightfield = data
['query']['logevents'][0]['params']['oldgroups'][o-1]
+ oldrightfieldexpiry = data
['query']['logevents'][0]['params']['oldmetadata'][o-1]['expiry']
+ if oldrightfieldexpiry != "infinity" :
+ chrightso = chrightso + oldrightfield + " (expiry: " +
datetime.strptime( oldrightfieldexpiry , "%Y-%m-%dT%H:%M:%SZ"
).strftime('%H:%M, %d %B %Y') + ")"
+ else:
+ chrightso = chrightso + oldrightfield
+ if o != lenoldrights - 1 :
+ chrightso = chrightso + ", "
+ o = o+1
+ if chrightso == "" :
+ chrightso = "(none)"
+ while n < lennewrights :
+ newrightfield = data
['query']['logevents'][0]['params']['newgroups'][n-1]
+ newrightfieldexpiry = data
['query']['logevents'][0]['params']['newmetadata'][n-1]['expiry']
+ if newrightfieldexpiry != "infinity" :
+ chrightsn = chrightsn + newrightfield + " (expiry: " +
datetime.strptime( newrightfieldexpiry , "%Y-%m-%dT%H:%M:%SZ"
).strftime('%H:%M, %d %B %Y') + ")"
+ else:
+ chrightsn = chrightsn + newrightfield
+ if n != lennewrights - 1 :
+ chrightsn = chrightsn + ", "
+ n = n+1
+ if chrightsn == "":
+ chrightsn = "(none)"
+ # end of check expiry
if extra:
print "!!! There are extra parameters!"
comment = found.group('comment')
@@ -1092,7 +1129,7 @@
bott = "06(bot) "
bot1.msg(
"%s%s03%s changed user rights for %s from 04%s to
04%s%s" %
- (selff, bott, usersource, usertarget, state1, state2,
comment))
+ (selff, bott, usersource, usertarget, chrightso,
chrightsn, comment))
elif "Special:Log/gblblock" in a:
if "gblock2" in a:
# [[Special:Log/gblblock]] gblock2 * Pathoschild *
globally blocked [[User:190.198.116.53]] (anonymous only, expires 15:18, 28
April 2009): crosswiki abuse, likely proxy
--
To view, visit https://gerrit.wikimedia.org/r/374051
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I572153dc5566378e55713dcb137f08828adeeb2a
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/stewardbots
Gerrit-Branch: master
Gerrit-Owner: Melos <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits