A discord bot for DevOps
Setting up a running version of DevBot is easy.
Follow the following steps:
- Clone the repository.
use: git clone git@github.com:DevOps-Utrecht/bot.git
or git clone https://github.com/DevOps-Utrecht/bot.git
- Create a virtualenv and install dependencies:
use: pipenv sync [--dev]
- 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.
- Run the bot
use: pipenv run start
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)
TOKEN
sets the Discord API key, which you can get from this website.
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.