[U] Update issue moderator to allow dynamic blacklist file
This commit is contained in:
parent
4a16cfec9b
commit
afb7092667
2 changed files with 9 additions and 3 deletions
2
tools/blacklist_users.csv
Normal file
2
tools/blacklist_users.csv
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Symbolic11
|
||||||
|
GentlemanMC
|
|
|
@ -1,21 +1,25 @@
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from github import Github
|
from github import Github
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
gh = Github(per_page=100, login_or_token=os.environ.get('GH_TOKEN'))
|
gh = Github(per_page=100, login_or_token=os.environ.get('GH_TOKEN'))
|
||||||
|
|
||||||
repo = gh.get_repo("hykilpikonna/hyfetch")
|
repo = gh.get_repo("hykilpikonna/hyfetch")
|
||||||
|
|
||||||
|
print("Running issue moderator...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
# Update blacklist every loop
|
||||||
|
blacklist = {v for v in Path("blacklist_users.csv").read_text().split("\n") if v}
|
||||||
iss = repo.get_issues(state='open')
|
iss = repo.get_issues(state='open')
|
||||||
|
|
||||||
for i in iss:
|
for i in iss:
|
||||||
if i.user.login in ['Symbolic11']:
|
if i.user.login in blacklist:
|
||||||
i.edit(title="[Redacted]", body="[Redacted by Content Moderation Bot]", state="closed")
|
i.edit(title="[Redacted]", body="[Redacted by Content Moderation Bot]", state="closed")
|
||||||
i.create_comment("Issue closed by bot for offensive content.")
|
i.create_comment("Issue closed by bot for offensive content.")
|
||||||
|
|
||||||
print(f"Closed {i.number}")
|
print(f"Closed {i.number}")
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(5)
|
Loading…
Reference in a new issue