Skip to content

GimmyFimmy/Snitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Application to send GitHub events in a specific Discord channels.

Getting started

Software requirements

Python 3.10 Windows 10/11

Installation (Via Terminal)

Tip

We recommend downloading the latest release to avoid bugs.

  1. Open the repository:
    cd /path/to/repository
    
  2. Create a new virtual environment:
    python -m venv .venv
    
  3. Activate the virtual environment:
    source .venv/bin/activate
    
  4. Update pip:
    pip install --upgrade pip
    
  5. Download packages:
    pip install -r requirements.txt
    

Creating Discord Bot

Information about how to create bot and get token can be found here.

Usage

Caution

This program is for personal use only. Do not share your tokens or text channel IDs with anyone.

First, we import snitch application. After that we call run method with properties.

Note

You can choose the channel to which event(s) will be sent or even ignore some type of event(s), according to your preference.

from snitch import *

Snitch.run(properties={
   "USER_REPO": "YOUR USERNAME/REPOSITORY HERE (REQUIRED) (EXAMPLE: GimmyFimmy/Snitch)",
   
   "GITHUB_TOKEN": "YOUR TOKEN HERE (REQUIRED)",
   "BOT_TOKEN": "YOUR TOKEN HERE (REQUIRED)",
   
   "PUSH_CHANNEL_ID": "YOUR CHANNEL ID HERE",
   "PULL_REQUEST_CHANNEL_ID": "YOUR CHANNEL ID HERE",
   "RELEASE_CHANNEL_ID": "YOUR CHANNEL ID HERE",
   "ISSUES_CHANNEL_ID": "YOUR CHANNEL ID HERE",
})

Customization

You can also change types of events, their titles and descriptions in a snitch/snitch.py file. This is how it looks:

_SAMPLES = {
    "push": {
        "title": "↗ Push from {data[pusher][name]}",
        "desc": "`Commit Messages: {data[head_commit][message]}`\n`Forced: {data[forced]}`",
    },
    "pull_request": {
        "title": "⤵ {data[pull_request][title]} was *{data[action]}* by {data[sender][login]}",
        "desc": "`Number: {data[number]}`",
    },
    "release": {
        "title": "⬇ {data[release][name]} was *{data[action]}* by {data[release][author][login]}",
        "desc": "`Pre Release: {data[release][prerelease]}`\n`Id: {data[release][id]}`",
    },
    "issues": {
        "title": "⚠ {data[issue][title]} was *{data[action]}* by {data[issue][user][login]}",
        "desc": "`Id: {data[issue][id]}`",
    },
}

Note

To access event data use {data[...]}, to go to the next line use \n.

Contribution

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

About

Application to manage GitHub webhook

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages