stoatrb

Stoatrb is a Ruby package (a.k.a. Gem) that allows you to make stoat.chat bots and use stoat.chat webhooks using the Ruby programming language. This package (a.k.a. Gem) is not officially endorsed by stoat.chat amd this is not an official stoat.chat product.

You need Ruby 3.0 or newer in order to use this package (Ruby 3.2 or newer is recommended)

[!NOTE] This package (a.k.a. Gem) is in an alpha state so expect things to be buggy and/or broken.

ToDo

This list contains a list of things that I know is broken and gotta fix. Contributing will be super helpful.

  • Fix reactions support

Setup

You can install Revoltrb through the following methods:

Method 1: Install from Gemfile

Add the following to your Gemfile file and run the "bundle install" command:

gem 'stoatrb'

or add the following to your Gemfile file.

gem 'stoatrb', git: 'https://gitlab.com/roxannewolf/stoatrb'

Troubleshooting

If you encounter the "Exited with code: 16 output:Ignoring debug-1.7.1 because its extensions are not built." error, most likely, there is something wrong with the parser package. This can be fixed by installing parser manually (gem install parser)

Usage

You can make a simple bot like this:

require 'stoatrb'

bot = Stoatrb::StoatBot.new('REVOLT_BOT_TOKEN_HERE')

bot.on_message do |message|
    next if message['author'] == bot.user_id
    content = message['content']&.downcase
    channel_id = message['channel']

    if content.include?("ping")
        bot.send_message(channel_id, text: "Pong!")
    end
end

bot.run

or you can make a bot with full prefix commands like this:

require 'stoatrb'

bot = Stoatrb::StoatBot.new('REVOLT_BOT_TOKEN_HERE', prefix: '!')

bot.command(:ping) do |message, args|
    channel_id = message['channel']
    bot.send_message(channel_id, text: "Pong! You sent: #{args.join(' ')}")
end

bot.run

Webhook example:

require 'stoatrb'
# Webhook url should look like this: https://stoat.chat/api/webhooks/<WEBHOOK_ID>/<WEBHOOK_TOKEN>
WEBHOOK_ID = ''
WEBHOOK_TOKEN = ''
webhook = StoatWebhooks::Webhook.new(WEBHOOK_ID, WEBHOOK_TOKEN)

webhook.send_message(
    content: "Stoatrb webhook message content",
)

Support and Help

If you need help with this ruby package (a.k.a. Gem), feel free to join the Roxanne Studios Stoat.chat Server and use the STOATRB category to talk about this package.

Contributing

We are working to support more of Stoat.chat's API. Remember, the creator of this package is only a Ruby beginner so contributing to this project will mean a lot and can help with more coverage with the Stoat.chat API. Opening issues and Pull requests are welcome at our Gitlab repo and Codeberg repo