屏蔽一些不友好的人

2022/3/4 GitHubReact

今天在 React 的 GitHub 仓库的 issues 上看到了很多人发表了很多不正当言论的 issues,很是无语💬,屎💩都喷到国外去了……

于是决定写✍🏻️一个脚本来屏蔽掉这些人

感谢 @sxzz (opens new window) 提供的数据 (opens new window),于是就有了下面的脚本👇🏻

import requests
import json

github_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
headers = { 'Authorization': 'token ' + github_token }

data_url = 'https://raw.githubusercontent.com/sxzz/github-block-tool/main/analyze.json'
get_data = lambda : json.loads(requests.get(data_url).text)

get_user_name = lambda data: list(map(lambda x: x['username'], data))
block_user = lambda user_name: requests.put(f'https://api.github.com/user/blocks/{user_name}',
                                            headers=headers)

def main():
    user_name = get_user_name(get_data())
    for name in user_name:
        status = block_user(name).status_code
        if (status == 204):
            print(f'@{name} is blocked')
        elif (status == 404):
            print(f'@{name} is not exist')
        elif (status == 422):
            print(f'@{name} is already blocked')
        else:
            print(f'@{name} with status code {status}')

if __name__ == '__main__':
    main()
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

最终屏蔽了以下账户,如有误杀劳烦您请联系我,先说声抱歉🙏🏻

文件链接 (opens new window)

Last Updated: 2022-03-20 05:37:58