Merge remote-tracking branch 'origin/master'

This commit is contained in:
Frisk 2020-11-14 10:26:28 +01:00
commit 9e4d14e9d6
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
3 changed files with 160 additions and 111 deletions

View file

@ -33,7 +33,7 @@
"debug": { "debug": {
"formatter": "standard", "formatter": "standard",
"class": "logging.handlers.TimedRotatingFileHandler", "class": "logging.handlers.TimedRotatingFileHandler",
"filename": "debug.log", "filename": "logs/debug.log",
"interval": 7, "interval": 7,
"when": "D", "when": "D",
"level": 0 "level": 0
@ -59,10 +59,6 @@
"show_footer": true, "show_footer": true,
"show_edit_changes": true, "show_edit_changes": true,
"embed_images": true, "embed_images": true,
"daily_overview": {
"color": 16312092,
"icon": ""
},
"new": { "new": {
"icon": "https://i.imgur.com/6HIbEq8.png", "icon": "https://i.imgur.com/6HIbEq8.png",
"color": "THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE" "color": "THIS COLOR DEPENDS ON EDIT SIZE, PLEASE DON'T CHANGE"
@ -77,11 +73,11 @@
}, },
"upload/upload": { "upload/upload": {
"icon": "https://i.imgur.com/egJpa81.png", "icon": "https://i.imgur.com/egJpa81.png",
"color": null "color": 12390624
}, },
"upload/revert": { "upload/revert": {
"icon": "https://i.imgur.com/egJpa81.png", "icon": "https://i.imgur.com/egJpa81.png",
"color": null "color": 12390624
}, },
"delete/delete": { "delete/delete": {
"icon": "https://i.imgur.com/BU77GD3.png", "icon": "https://i.imgur.com/BU77GD3.png",
@ -93,27 +89,27 @@
}, },
"delete/restore": { "delete/restore": {
"icon": "https://i.imgur.com/9MnROIU.png", "icon": "https://i.imgur.com/9MnROIU.png",
"color": null "color": 1
}, },
"delete/revision": { "delete/revision": {
"icon": "https://i.imgur.com/1gps6EZ.png", "icon": "https://i.imgur.com/1gps6EZ.png",
"color": null "color": 1
}, },
"delete/event": { "delete/event": {
"icon": "https://i.imgur.com/1gps6EZ.png", "icon": "https://i.imgur.com/1gps6EZ.png",
"color": null "color": 1
}, },
"merge/merge": { "merge/merge": {
"icon": "https://i.imgur.com/uQMK9XK.png", "icon": "https://i.imgur.com/uQMK9XK.png",
"color": null "color": 25600
}, },
"move/move": { "move/move": {
"icon": "https://i.imgur.com/eXz9dog.png", "icon": "https://i.imgur.com/eXz9dog.png",
"color": null "color": 25600
}, },
"move/move_redir": { "move/move_redir": {
"icon": "https://i.imgur.com/UtC3YX2.png", "icon": "https://i.imgur.com/UtC3YX2.png",
"color": null "color": 25600
}, },
"block/block": { "block/block": {
"icon": "https://i.imgur.com/g7KgZHf.png", "icon": "https://i.imgur.com/g7KgZHf.png",
@ -129,167 +125,219 @@
}, },
"protect/protect": { "protect/protect": {
"icon": "https://i.imgur.com/bzPt89Z.png", "icon": "https://i.imgur.com/bzPt89Z.png",
"color": null "color": 16312092
}, },
"protect/modify": { "protect/modify": {
"icon": "https://i.imgur.com/bzPt89Z.png", "icon": "https://i.imgur.com/bzPt89Z.png",
"color": null "color": 16312092
}, },
"protect/move_prot": { "protect/move_prot": {
"icon": "https://i.imgur.com/bzPt89Z.png", "icon": "https://i.imgur.com/bzPt89Z.png",
"color": null "color": 16312092
}, },
"protect/unprotect": { "protect/unprotect": {
"icon": "https://i.imgur.com/2wN3Qcq.png", "icon": "https://i.imgur.com/2wN3Qcq.png",
"color": null "color": 16312092
}, },
"import/upload": { "import/upload": {
"icon": "", "icon": "",
"color": null "color": 65280
}, },
"import/interwiki": { "import/interwiki": {
"icon": "https://i.imgur.com/sFkhghb.png", "icon": "https://i.imgur.com/sFkhghb.png",
"color": null "color": 65280
}, },
"rights/rights": { "rights/rights": {
"icon": "", "icon": "",
"color": null "color": 16711680
}, },
"abusefilter/abusefilter": { "abusefilter/abusefilter": {
"icon": "https://i.imgur.com/Sn2NzRJ.png", "icon": "https://i.imgur.com/Sn2NzRJ.png",
"color": null "color": 16711680
}, },
"abusefilter/modify": { "abusefilter/modify": {
"icon": "https://i.imgur.com/Sn2NzRJ.png", "icon": "https://i.imgur.com/Sn2NzRJ.png",
"color": null "color": 16711680
}, },
"abusefilter/create": { "abusefilter/create": {
"icon": "https://i.imgur.com/Sn2NzRJ.png", "icon": "https://i.imgur.com/Sn2NzRJ.png",
"color": null "color": 16711680
}, },
"interwiki/iw_add": { "interwiki/iw_add": {
"icon": "https://i.imgur.com/sFkhghb.png", "icon": "https://i.imgur.com/sFkhghb.png",
"color": null "color": 16711680
}, },
"interwiki/iw_edit": { "interwiki/iw_edit": {
"icon": "https://i.imgur.com/sFkhghb.png", "icon": "https://i.imgur.com/sFkhghb.png",
"color": null "color": 16711680
}, },
"interwiki/iw_delete": { "interwiki/iw_delete": {
"icon": "https://i.imgur.com/sFkhghb.png", "icon": "https://i.imgur.com/sFkhghb.png",
"color": null "color": 16711680
}, },
"curseprofile/comment-created": { "curseprofile/comment-created": {
"icon": "https://i.imgur.com/Lvy5E32.png", "icon": "https://i.imgur.com/Lvy5E32.png",
"color": null "color": 16089376
}, },
"curseprofile/comment-edited": { "curseprofile/comment-edited": {
"icon": "https://i.imgur.com/Lvy5E32.png", "icon": "https://i.imgur.com/Lvy5E32.png",
"color": null "color": 16089376
}, },
"curseprofile/comment-deleted": { "curseprofile/comment-deleted": {
"icon": "", "icon": "",
"color": null "color": 16089376
}, },
"curseprofile/comment-purged":{ "curseprofile/comment-purged":{
"icon":"", "icon":"",
"color":null "color":16089376
}, },
"curseprofile/comment-replied": { "curseprofile/comment-replied": {
"icon": "https://i.imgur.com/hkyYsI1.png", "icon": "https://i.imgur.com/hkyYsI1.png",
"color": null "color": 16089376
}, },
"curseprofile/profile-edited": { "curseprofile/profile-edited": {
"icon": "", "icon": "",
"color": null "color": 16089376
}, },
"contentmodel/change": { "contentmodel/change": {
"icon": "", "icon": "",
"color": null "color": 25600
}, },
"cargo/deletetable": { "cargo/deletetable": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"cargo/createtable": { "cargo/createtable": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"cargo/replacetable": { "cargo/replacetable": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"cargo/recreatetable": { "cargo/recreatetable": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"sprite/sprite": { "sprite/sprite": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"sprite/sheet": { "sprite/sheet": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"sprite/slice": { "sprite/slice": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"managetags/create": { "managetags/create": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"managetags/delete": { "managetags/delete": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"managetags/activate": { "managetags/activate": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"managetags/deactivate": { "managetags/deactivate": {
"icon": "", "icon": "",
"color": null "color": 16776960
}, },
"tag/update": { "tag/update": {
"icon": "", "icon": "",
"color": null "color": 16776960
},
"newusers/autocreate": {
"icon": "",
"color": 65280
},
"newusers/byemail": {
"icon": "",
"color": 65280
},
"newusers/create": {
"icon": "",
"color": 65280
},
"newusers/create2": {
"icon": "",
"color": 65280
},
"newusers/newusers": {
"icon": "",
"color": 65280
},
"managewiki/delete": {
"icon": "",
"color": 8421504
},
"managewiki/lock": {
"icon": "",
"color": 8421504
},
"managewiki/namespaces": {
"icon": "",
"color": 8421504
},
"managewiki/namespaces-delete": {
"icon": "",
"color": 8421504
},
"managewiki/rights": {
"icon": "",
"color": 8421504
},
"managewiki/settings": {
"icon": "",
"color": 8421504
},
"managewiki/undelete": {
"icon": "",
"color": 8421504
},
"managewiki/unlock": {
"icon": "",
"color": 8421504
}, },
"suppressed": { "suppressed": {
"icon": "https://i.imgur.com/1gps6EZ.png", "icon": "https://i.imgur.com/1gps6EZ.png",
"color": 8092539 "color": 1
}, },
"discussion/forum/post": { "discussion/forum/post": {
"icon": "", "icon": "",
"color":null "color": 54998
}, },
"discussion/forum/reply": { "discussion/forum/reply": {
"icon": "", "icon": "",
"color":null "color": 54998
}, },
"discussion/forum/poll": { "discussion/forum/poll": {
"icon": "", "icon": "",
"color":null "color": 54998
}, },
"discussion/forum/quiz": { "discussion/forum/quiz": {
"icon": "", "icon": "",
"color":null "color": 54998
}, },
"discussion/wall/post": { "discussion/wall/post": {
"icon": "", "icon": "",
"color":null "color": 3752525
}, },
"discussion/wall/reply": { "discussion/wall/reply": {
"icon": "", "icon": "",
"color":null "color": 3752525
}, },
"discussion/comment/post": { "discussion/comment/post": {
"icon": "", "icon": "",
"color":null "color": 10802
}, },
"discussion/comment/reply": { "discussion/comment/reply": {
"icon": "", "icon": "",
"color":null "color": 10802
} }
} }
} }

View file

@ -214,7 +214,7 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH)) link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
content = "🔒 "+_("[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(author=author, author_url=author_url, content = "🔒 "+_("[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
settings=change["logparams"]["description"]+_(" [cascading]") if "cascade" in change["logparams"] else "", settings=change["logparams"]["description"]+(_(" [cascading]") if "cascade" in change["logparams"] else ""),
comment=parsed_comment) comment=parsed_comment)
elif action == "protect/modify": elif action == "protect/modify":
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH)) link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))
@ -222,7 +222,7 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c
"[{author}]({author_url}) modified protection settings of [{article}]({article_url}) to: {settings}{comment}").format( "[{author}]({author_url}) modified protection settings of [{article}]({article_url}) to: {settings}{comment}").format(
author=author, author_url=author_url, author=author, author_url=author_url,
article=change["title"], article_url=link, article=change["title"], article_url=link,
settings=change["logparams"]["description"] + _(" [cascading]") if "cascade" in change["logparams"] else "", settings=change["logparams"]["description"] + (_(" [cascading]") if "cascade" in change["logparams"] else ""),
comment=parsed_comment) comment=parsed_comment)
elif action == "protect/unprotect": elif action == "protect/unprotect":
link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH)) link = link_formatter(create_article_path(change["title"], WIKI_ARTICLE_PATH))

View file

@ -112,9 +112,11 @@ def profile_field_name(name, embed, lang):
class ContentParser(HTMLParser): class ContentParser(HTMLParser):
current_tag = "" current_tag = ""
last_ins = None
last_del = None
empty = False
small_prev_ins = "" small_prev_ins = ""
small_prev_del = "" small_prev_del = ""
added = False
def __init__(self, lang): def __init__(self, lang):
super().__init__() super().__init__()
@ -125,58 +127,57 @@ class ContentParser(HTMLParser):
def handle_starttag(self, tagname, attribs): def handle_starttag(self, tagname, attribs):
if tagname == "ins" or tagname == "del": if tagname == "ins" or tagname == "del":
self.current_tag = tagname self.current_tag = tagname
if tagname == "td" and 'diff-addedline' in attribs[0]: if tagname == "td" and "diff-addedline" in attribs[0] and self.ins_length <= 1000:
self.current_tag = tagname + "a" self.current_tag = "tda"
if tagname == "td" and 'diff-deletedline' in attribs[0]: self.last_ins = ""
self.current_tag = tagname + "d" if tagname == "td" and "diff-deletedline" in attribs[0] and self.del_length <= 1000:
if tagname == "td" and 'diff-marker' in attribs[0]: self.current_tag = "tdd"
self.added = True self.last_del = ""
if tagname == "td" and "diff-empty" in attribs[0]:
self.empty = True
def handle_data(self, data): def handle_data(self, data):
data = escape_formatting(data) data = escape_formatting(data)
if self.current_tag == "ins" and self.ins_length <= 1000: if self.current_tag == "ins" and self.ins_length <= 1000:
self.ins_length += len("**" + data + '**') self.ins_length += len("**" + data + "**")
if self.ins_length <= 1000: if self.ins_length <= 1000:
self.small_prev_ins = self.small_prev_ins + "**" + data + '**' self.last_ins = self.last_ins + "**" + data + "**"
else:
self.small_prev_ins = self.small_prev_ins + self.more
if self.current_tag == "del" and self.del_length <= 1000: if self.current_tag == "del" and self.del_length <= 1000:
self.del_length += len("~~" + data + '~~') self.del_length += len("~~" + data + "~~")
if self.del_length <= 1000: if self.del_length <= 1000:
self.small_prev_del = self.small_prev_del + "~~" + data + '~~' self.last_del = self.last_del + "~~" + data + "~~"
else: if self.current_tag == "tda" and self.ins_length <= 1000:
self.small_prev_del = self.small_prev_del + self.more
if (self.current_tag == "afterins" or self.current_tag == "tda") and self.ins_length <= 1000:
self.ins_length += len(data) self.ins_length += len(data)
if self.ins_length <= 1000: if self.ins_length <= 1000:
self.small_prev_ins = self.small_prev_ins + data self.last_ins = self.last_ins + data
else: if self.current_tag == "tdd" and self.del_length <= 1000:
self.small_prev_ins = self.small_prev_ins + self.more
if (self.current_tag == "afterdel" or self.current_tag == "tdd") and self.del_length <= 1000:
self.del_length += len(data) self.del_length += len(data)
if self.del_length <= 1000: if self.del_length <= 1000:
self.small_prev_del = self.small_prev_del + data self.last_del = self.last_del + data
else:
self.small_prev_del = self.small_prev_del + self.more
if self.added:
if data == '+' and self.ins_length <= 1000:
self.ins_length += 1
if self.ins_length <= 1000:
self.small_prev_ins = self.small_prev_ins + '\n'
else:
self.small_prev_ins = self.small_prev_ins + self.more
if data == '' and self.del_length <= 1000:
self.del_length += 1
if self.del_length <= 1000:
self.small_prev_del = self.small_prev_del + '\n'
else:
self.small_prev_del = self.small_prev_del + self.more
self.added = False
def handle_endtag(self, tagname): def handle_endtag(self, tagname):
if tagname == "ins":
self.current_tag = "afterins"
elif tagname == "del":
self.current_tag = "afterdel"
else:
self.current_tag = "" self.current_tag = ""
if tagname == "ins":
self.current_tag = "tda"
elif tagname == "del":
self.current_tag = "tdd"
elif tagname == "tr":
if self.last_ins is not None:
self.ins_length += 1
if self.empty and not self.last_ins.isspace() and "**" not in self.last_ins:
self.ins_length += 4
self.last_ins = "**" + self.last_ins + "**"
self.small_prev_ins = self.small_prev_ins + "\n" + self.last_ins
if self.ins_length > 1000:
self.small_prev_ins = self.small_prev_ins + self.more
self.last_ins = None
if self.last_del is not None:
self.del_length += 1
if self.empty and not self.last_del.isspace() and "~~" not in self.last_del:
self.del_length += 4
self.last_del = "~~" + self.last_del + "~~"
self.small_prev_del = self.small_prev_del + "\n" + self.last_del
if self.del_length > 1000:
self.small_prev_del = self.small_prev_del + self.more
self.last_del = None
self.empty = False