Refactor for ActiveRecord and Config Files

Update Custom Commands to leverage ActiveRecord and save commands to a
database. By default, it will use SQLite. Configuration for this (and
potential configuration for PostgreSQL and MySQL) live in
`config/db.yml`. Inculde a Rakefile for handling DB creation and
migrations.

Rakefile: Add Rakefile to handle running the bot, and DB management
Gemfile: Update with new gem dependencies
db/migrate/*: ActiveRecord migrations for Custom Command
custom_commands.rb: Update to leverage ActiveRecord

Leverage the Rakefile to start the bot, removing the binary file. Update
the Dockerfile to also leverage the Rakefile.

Dockerfile: Update to use Rakefile, and install new dependencies
chronicle: Remove unnecessary start file

Refactor the `chronicle_bot` file into `chronicle` and `matrix`

chronicle.rb: General Chronicle setup
matrix.rb: Start a Matrix-specific bot

Update the bot to read configuration from files, instead of either the
environment, or hard-coded values.

config/db.yml: Database configuration
config/bot.yml: General bot configuration

Update the README to reflect the above change with regards to running
the bot either using the Rakefile, or using a Docker container.
This commit is contained in:
Bill Niblock 2021-02-27 19:40:54 -05:00
parent b919de11f5
commit ce06aa568b
11 changed files with 312 additions and 136 deletions

7
config/bot.yml Normal file
View file

@ -0,0 +1,7 @@
matrix:
homeserver: ''
token: ''
log:
file: 'chronicle.log'
debug: 1

19
config/db.yml Normal file
View file

@ -0,0 +1,19 @@
# SQLite Configuration
adapter: 'sqlite3'
database: 'db/chronicle-bot.db'
# PostgreSQL Configuration
# adapter: 'postgresql'
# database: 'chronicle-bot'
# host: 'localhost:1234'
# username: 'chronicle'
# password: 'ch4ng3m3'
# encoding: 'utf8'
# MySQL Configuration
# adapter: 'mysql2'
# database: 'chronicle-bot'
# host: 'localhost:1234'
# username: 'chronicle'
# password: 'ch4ng3m3'
# encoding: 'utf8'