-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (25 loc) · 921 Bytes
/
main.py
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
29
30
31
import settings
from github import Github
import json
import requests
GITHUB_TOKEN = settings.GITHUB_TOKEN
DISCORD_WEBHOOK_URL = settings.DISCORD_WEBHOOK_URL
USER_NAME = settings.USER_NAME
if __name__ == '__main__':
github = Github(GITHUB_TOKEN)
repos = github.get_user(USER_NAME).get_repos()
contents = []
total_views = 0
total_clones = 0
for repo in repos:
views = repo.get_views_traffic()["count"]
clones = repo.get_clones_traffic()["count"]
contents.append(f"repo: {repo.name}\nviews: {str(views)}\nclones: {str(clones)}\n\n")
total_clones += clones
total_views += views
res = requests.post(DISCORD_WEBHOOK_URL,
headers=({'Content-Type': "application/json"}),
data=json.dumps({
'content': "".join(str(content) for content in contents) + f"\ntotal views: {total_views}\ntotal clones: {total_clones}"
})
)