Skip to content

ikngtty/free-verse-discord-bot

Repository files navigation

俳句じゃないやつ検出bot

A Discord bot to detect free verses.

Usage

Detection

The bot joining to your server detects free verses and reports it by a discord message automatically.

Commands

Commands can be run by a mention to the bot.

Commands:

  • @<bot> mecab <text>
    • Shows [MeCab][mecab] result about the specified text by a discord message.

Development

Requirements

When running or deploying this bot, you need to create .env file in the project directory by copying .env.template file or to set the environment variables.

  • in Local
    • set the env vars -> they are used (.env file is ignored)
    • prepare .env file -> they are loaded by dotenv gem
  • with Docker Compose
    • set the env vars -> they are passed to the container by Docker Compose and are used there (.env file is ignored)
    • prepare .env file -> they are loaded by Docker Compose and are used in the container
  • heroku
    • set the env vars -> they are used

Run

with Docker Compose

Ruby's version is specified by /.Dockerfile.

# prepare and run
docker-compose up -d --build

in Local

Ruby's version is specified by /.ruby-version.

For running, these are required:

# prepare
bundle install

# run
bundle exec ruby main.rb

Deploy

heroku create free-verse-discord-bot
heroku stack:set container
heroku config:set DISCORD_BOT_TOKEN=$DISCORD_BOT_TOKEN
git push heroku master
heroku addons:create heroku-redis:hobby-dev # *1
heroku ps:scale bot=1

*1: This necessity is declared in setup steps in the heroku.yml manifest file, but by this document, automatic installations triggerd by it seem to be a beta function. So we should install the add-on manually (or use the beta function by following the steps in the document).

or use GitHub Integration.

Test

with Docker

docker run --name freeverse_test ikngtty/freeverse rspec

in Local

bundle exec rspec

Lint

in Local

bundle exec rubocop

Inspect

Enter this command in Local and we can get our bot's information through Discord REST API.

bundle exec ruby script/inspect.rb