airbot

command module
v0.0.0-...-1b29edf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 15 Imported by: 0

README

airbot

CodeFactor GoReportCard Go version godoc

High-performance multi-platform utility bot written in Go.

Currently under development.

Support planned for many features (gamba, etc.) and platforms (Twitch, Discord, etc.).

Commands

Commands are available on the commands page.

Live instance

The bot is currently running on the Twitch account af2bot.

It's hosted on a Google Cloud Platform e2-micro Compute Engine instance.

Add/remove bot

To add the bot to your channel, type $join in af2bot's chat.

To have the bot leave your channel, type $leave in your chat.

Development

Running locally

To run the bot locally:

  1. Install Docker
  2. Clone the repository and change into it
  3. Copy config/config_example.toml to config.toml in the main directory
  4. Fill in the empty fields in config.toml, notably API keys and usernames
  5. Copy .example.env to .env in the main directory
  6. Set a value for POSTGRES_PASSWORD in .env
  7. Run ./start.sh
Documentation

Some documentation is generated.

After making changes, run ./gen-docs.sh from the main directory to regenerate the docs.

Running in production

To run in production (on a debian machine):

  1. Clone the repository and change into it
  2. Run cd scripts
  3. Run ./setup-vm-debian.sh to set up the environment
  4. Fill in the empty fields in config.toml, notably API keys and usernames
  5. Set a value for POSTGRES_PASSWORD in .env
  6. (optional): If running in a GCE container, follow these instructions to set your default Docker log-driver to gcplogs (in /etc/docker/daemon.json) to send the Docker logs to Google Cloud Logging.
  7. Reboot the machine
  8. Run ./start-prod.sh to start the bot
Maintenance

To update the bot, run ./update.sh.

To stop the bot, run ./stop-prod.sh.

To connect to the bot's container while it's running, run docker attach airbot-server-1.

To connect to the database's container while it's running, run docker attach airbot-database-1.

To disconnect from a container, press CTRL-p CTRL-q.

Updating database

To update Postgres to a new major version (example is moving from version 14 to 15):

  1. Make sure the version-specific migrator image is available here

  2. Run:

    docker run --rm \
        --env-file=.env \
        -e POSTGRES_INITDB_ARGS="-U airbot" \
        -v airbot_postgres-14-data:/var/lib/postgresql/14/data \
        -v airbot_postgres-15-data:/var/lib/postgresql/15/data \
        tianon/postgres-upgrade:14-to-15
    
    • Note that the POSTGRES_INITDB_ARGS value should match the PGUSER value in your .env file.
    • If the upgrade fails, run docker volume rm airbot_postgres-15-data and try again.
  3. Run:

    docker run --rm \
        -v airbot_postgres-14-data:/var/lib/postgresql/14/data \
        -v airbot_postgres-15-data:/var/lib/postgresql/15/data \
        busybox \
        cp /var/lib/postgresql/14/data/pg_hba.conf /var/lib/postgresql/15/data/pg_hba.conf
    
  4. Update docker-compose.yml to use the new Postgres image

    • Under services.database, change image from postgres:14 to postgres:15
  5. Update docker-compose.yml to use the new volume

    • Under volumes.postgres-data, change name from airbot_postgres-14-data to airbot_postgres-15-data

Documentation

Overview

Package main contains the main logic for airbot.

Directories

Path Synopsis
apiclients
bible
Package bible provides an API client to the bible-api.com API.
Package bible provides an API client to the bible-api.com API.
bible/bibletest
Package bibletest provides helpers for testing connections to the Bible API.
Package bibletest provides helpers for testing connections to the Bible API.
ivr
Package ivr provides an API client to the ivr.fi API.
Package ivr provides an API client to the ivr.fi API.
ivr/ivrtest
Package ivrtest provides helpers for testing connections to the IVR API.
Package ivrtest provides helpers for testing connections to the IVR API.
kick
Package kick provides an API client to the Kick API.
Package kick provides an API client to the Kick API.
pastebin
Package pastebin handles interactions with the Pastebin API.
Package pastebin handles interactions with the Pastebin API.
pastebin/pastebintest
Package pastebintest provides helpers for testing connections to the Pastebin API.
Package pastebintest provides helpers for testing connections to the Pastebin API.
seventv
Package seventv provides a client to the 7TV API.
Package seventv provides a client to the 7TV API.
seventv/gqltypes
Package gqltypes contains types used in the 7TV GraphQL API.
Package gqltypes contains types used in the 7TV GraphQL API.
seventv/seventvtest
Package seventvtest provides helpers for testing connections to the 7TV API.
Package seventvtest provides helpers for testing connections to the 7TV API.
supinic
Package supinic contains a client for the Supinic API.
Package supinic contains a client for the Supinic API.
supinic/supinictest
Package ivrtest provides helpers for testing connections to the Supinic API.
Package ivrtest provides helpers for testing connections to the Supinic API.
twitchtest
Package provides helpers for testing connections to the Twitch API.
Package provides helpers for testing connections to the Twitch API.
Package base provides base structs used throughout the application.
Package base provides base structs used throughout the application.
arg
Package argument contains command parameter/argument types.
Package argument contains command parameter/argument types.
Package cache provides an interface to the local Redis cache.
Package cache provides an interface to the local Redis cache.
cachetest
Package cachetest provides a fake cache for testing.
Package cachetest provides a fake cache for testing.
Package commands contains all commands that can be run and a command handler.
Package commands contains all commands that can be run and a command handler.
admin
Package admin handles bot administration commands.
Package admin handles bot administration commands.
basecommand
Package basecommand contains shared types and utilities for command handlers.
Package basecommand contains shared types and utilities for command handlers.
botinfo
Package botinfo implements commands that return info about the bot.
Package botinfo implements commands that return info about the bot.
bulk
Package bulk handles commands that perform bulk operations.
Package bulk handles commands that perform bulk operations.
commandtest
Package commandtest provides helpers for testing commands.
Package commandtest provides helpers for testing commands.
echo
Package echo implements commands that do simple echoes.
Package echo implements commands that do simple echoes.
fun
Package fun implements fun commands that hit APIs.
Package fun implements fun commands that hit APIs.
gamba
Package gamba implements gamba commands.
Package gamba implements gamba commands.
kick
Package kick implements Kick commands.
Package kick implements Kick commands.
moderation
Package moderation implements moderation commands.
Package moderation implements moderation commands.
seventv
Package seventv implements 7TV commands.
Package seventv implements 7TV commands.
twitch
Package twitch implements Twitch commands.
Package twitch implements Twitch commands.
Package config handles reading the config data.
Package config handles reading the config data.
Package database handles connections to the database.
Package database handles connections to the database.
databasetest
Package databasetest provides utilities for database testing.
Package databasetest provides utilities for database testing.
models
Package models defines database data models.
Package models defines database data models.
Documentation generator.
Documentation generator.
Package gamba handles gamba-related things.
Package gamba handles gamba-related things.
Package permission contains permission levels.
Package permission contains permission levels.
Package platforms contains the Platform interface and related.
Package platforms contains the Platform interface and related.
twitch
Package twitch handles Twitch-specific logic.
Package twitch handles Twitch-specific logic.
testing
fakeserver
Package fakeserver provides a fake HTTP server for testing.
Package fakeserver provides a fake HTTP server for testing.
Package utils contains utility functions that don't make sense to have their own namespaced packages.
Package utils contains utility functions that don't make sense to have their own namespaced packages.
cleanup
Package cleanup provides a way to register functions for cleanup and run them.
Package cleanup provides a way to register functions for cleanup and run them.
restart
Package restart provides a way for a command to restart the bot.
Package restart provides a way for a command to restart the bot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL