gitmon/main.py
2023-11-10 23:20:43 -05:00

34 lines
666 B
Python

"""GitMon"""
import time
from loguru import logger
from gitmon.api import GitHubApi
from gitmon.logger import setup_logger
from config import token
def log_event(event):
event_type = event.get('type')
repo = event.get('repo')
actor = event.get('actor')
logger.info(f'{event_type}:\t{repo["name"]}, {actor["login"]}')
def main():
"""Main entry point."""
setup_logger()
api = GitHubApi(token)
while True:
events = api.get_events()
for event in events:
if event['type'] in ['CreateEvent', 'DeleteEvent']:
log_event(event)
time.sleep(10)
if __name__ == '__main__':
main()