Code Monkey home page Code Monkey logo

gitbot's Introduction

What is GitBot?

GitBot is a Discord bot which aims to provide basic integration between Discord servers and GitHub repositories.

Currently, GitBot allows users to subscribe a Discord server's channel to a GitHub repository that they own. Then, GitBot will send messages to that channel providing notification of newly pushed commits and pull request interactions.

How does it work?

GitBot makes extensive use of OAuth and GitHub's public API to perform it's tasks.

When adding GitBot to your Discord server, Discord's OAuth service is used to authorize GitBot to join your server.

When subscribing a Discord server's channel to a GitHub repository, GitBot will instruct you to visit a link on our web server which redirects to GitHub's OAuth portal. Once you sign in and give GitBot the authorization it needs, it creates a webhook in the specified repository using an access token obtained from GitHub's API once you provide authorization.

This webhook instructs GitHub to send us a POST request with an event payload any time someone:

  • pushes to the repository
  • opens a pull request
  • closes a pull request
  • re-opens a pull request.

Upon receiving this payload, we use its contents to determine the proper message to send to Discord. Once this is determined and the message is constructed, GitBot sends it to the channel.

Security

When GitBot creates a Webhook, a secret hash is generated and stored in GitBot's database. Then, anytime a payload is received from a webhook, we pull up the stored secret and make sure it matches the one provided by GitHub. This ensures that webhook payloads are not tampered with, and provides an additional layer of security to the end user.

Setup

GitBot requires a keys.ts file to be present in the src/config folder. This contains config options and keys that GitBot needs to run.

An example keys.ts file is below:

export default {
	SERVER_PORT: 8080,
	GITHUB_CALLBACK_HOST: "123.123.123.123",
	DISCORD_CLIENT_ID: "DISCORD_CLIENT_ID_HERE",
	BOT_TOKEN: "BOT_TOKEN_HERE",
	GITHUB_CLIENT_ID: "GITHUB_CLIENT_ID_HERE",
	GITHUB_CLIENT_SECRET: "GITHUB_CLIENT_SECRET_HERE",
	MYSQL: {
		HOST: "localhost",
		USER: "USER_HERE",
		PASSWORD: "PASSWORD_HERE",
		DATABASE: "GitBot"
	}
};

gitbot's People

Contributors

dsnidr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.