Skip to content

DevOps-Utrecht/bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps-Bot

A discord bot for DevOps

Build Status Codacy Badge License: MIT Code style: black GitHub issues GitHub forks GitHub stars meme

Set-up

Setting up a running version of DevBot is easy.

Follow the following steps:

  1. Clone the repository.

use: git clone git@github.com:DevOps-Utrecht/bot.git or git clone https://github.com/DevOps-Utrecht/bot.git

  1. Create a virtualenv and install dependencies:

use: pipenv sync [--dev]

  1. Make a .env file.

Create a .env file in the root directory and place the required variables in it, for example:

TOKEN=1234567890
DEFAULT_CHANNEL=461951313547362318

Check the end of this README for more info.

  1. Run the bot

use: pipenv run start

Contributing Commands

DevBot uses a modular command system which makes it very easy for multiple developers to contribute commands.

To start make a python file in devbot/commands.

Use the @Command([Name, alias*]) decorator to register functions as commands.

Commands are coroutines so make sure to use async def when defining them.

Example:

#example.py

from devbot.registry import Command

@Command('ping')
async def ping_command(*_args, **_kwargs):
    """ On !ping replies pong! """
    return 'pong!'

@Command(['echo', 'repeat'])
async def echo_command(message_contents, *_args, **_kwargs):
    """ On !echo string or !repeat string replies with string """
    return ' '.join(message_contents)

Required .env variables

TOKEN sets the Discord API key, which you can get from this website.

Optional .env variables

CONSOLE_LOGLEVEL sets the loglevel of what log messages get sent to the console. This value can be DEBUG, INFO (Default), WARNING, ERROR and CRITICAL.

FILE_LOGLEVEL sets the loglevel of what log messages get sent to the log file (/logs/bot.log). This value can be DEBUG (Default), INFO, WARNING, ERROR and CRITICAL.

DATABASE sets the url to the database for the bot. A SQLite database will be created automatically if this variable is missing. Using a different database than SQLite, might require installing additional dependencies.

REMINDER_CHANNEL sets the default channel id. Any delayed message without a specific channel passed will use this channel to post to.