Files
ss14-wl/Tools/notify_discord_push.py
Pupchansky f80b33a60a Починил дискорд-чейнджлог
- wl-remove: Электродемон вырезан до лучших времён:pepe_life:
2024-09-28 15:53:48 +05:00

53 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
import os
import json
import notify_discord
COMMITS = json.loads(os.environ["COMMITS"])
PR_NOTIFY_WEBHOOK = os.environ["PR_NOTIFY_WEBHOOK"]
# божи упаси(дебаг строка)
def main():
content = ""
content_dict: dict[str, list[str]] = {
}
peoples = ['Fanolli', 'mosleyos']
for commit in COMMITS:
author = commit["author"]["username"]
if (author not in peoples):
print(f"{author} не был найден среди участников вайтлист организаций: {peoples}!")
continue
message = commit['message']
body = notify_discord.format_body(message)
if (body == "" or body.isspace()):
continue
if content_dict.get(author) == None:
content_dict[author] = [body]
else:
content_dict[author].append(body)
for author, messages in content_dict.items():
message = str.join("\n", messages)
message += f"Автор изменений: {author}\n"
content += message + "\n"
if content == "" or content.isspace():
print("В тексте не найдено :cl: тега и элементов add/remove... и т.д.")
print("Ошибка при отправке оповещения. Оно было пустым!")
return
notify_discord.send_discord(content, PR_NOTIFY_WEBHOOK)
if __name__ == '__main__':
main()