Git Product home page Git Product logo

birdbot's Introduction

Birdbot

A python bot to execute commands on Linux or Kubernetes systems with the use of Discord as a medium.

I made this bot so that ultimately I could make it so users on Discord would not need to have access to the actual box that some game servers would run on so that they could fetch logs or restart the game server if needed.

Since then I have refined the bot and made it so that I can run kubectl commands with the addition of a Service Account on my Kubernetes Clusters.

You may use this bot either as a container image or with a simple python command. The bot is compatible with python 3.8.

Please note that it is expected that you will clone this repo and add/remove your own features as needed rather than use this as is.

Environmental Variables

Envar Purpose Default
PUID=1000 To set the UserID for the bot user 1000
PGID=1000 To set the GroupID for the bot user 1000
HOSTNAME=birdbot Set the hostname of the container for easier identification when invoking !test. birdbot
TOKEN=token This is required to run the bot. If you don't set this the bot will continuously crash. token THIS WILL FAIL IF LEFT DEFAULT
PREFIX=! The prefix you would like to use to execute commands eg. !test or -test !

Using with Kubernetes

This is the intended use of the bot. Before doing this you will need to build the image using docker and to push the image to a registry of your choosing as Kubernetes does not use Local images and only images from a registry. For this example we will be using DockerHub since it's the most common.

  1. First clone the repo. git clone https://github.com/unixbird/birdbot.git

  2. cd birdbot

  3. docker build . -t dockerusername/examplename --no-cache (The --no-cache is used because whenever I build the image it may already have the adding of the python script cached. This is to insure that we get the newest script that was modified.)

  4. docker push dockerusername/examplename After you push this to a registry you will need to setup a Service Account for your deployment/pod.

  5. kubectl create ns examplename <<< This is optional if you don't intend to have the resources in a different namespace other than default.

  6. From the examples folder, we will use the serviceaccount.yml file. After you edit it to your needs run: kubectl apply -f examples/serviceaccount.yml -n examplenamespace

  7. After this step you may go ahead and run: kubectl apply -f examples/deployment.yml -n examplenamespace

    The bot should be up. You can check with the kubectl -n examplename logs -l app=birdbot to see the (Bot Ready) message. If the bot is crashing make sure you have the correct Secret token inserted into the ENVAR. If you don't receive an error go ahead and head over to the Discord Developer portal and create a bot link to invite the bot to your discord.

Using this with python

By far the simplest method but not it's intended use. All that you would need to do is insert your Bot Token into the ('TOKEN') field after you have edited the python script to your liking and run:

python birdbot.py

After this the bot will be running and you will need to invite it to the Guild (Discord Server) by creating an invite link from the Discord Developer portal

The default command to test is !test in the discord channel.


birdbot's People

Contributors

unixbird avatar

Watchers

 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.