Shimogawa / rubirai

Ruby library for mirai-api-http

Home Page:https://www.rebuild.moe/rubirai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rubirai

Gem Version CI codecov Maintainability Inline docs FOSSA Status

A light-weight Mirai QQ bot http interface lib for Ruby.

中文 | Rubydocs

Description

This library is designed specifically for integration with mirai-api-http. Mirai is a QQ bot framework. The relationship is like this:

mirai <-jvm-> mirai-console <-plugin-> mirai-api-http <-http-> rubirai

Prerequisite

Install mirai-api-http and configure its setting.yml file.

Now its easier to enable singleMode if you have only one account in the mirai console.

Note that you must enable Http Adapter with configuration of http under adapterSettings. More mode support to come.

Usage

First, download the package using gem. In your Gemfile, add

gem 'rubirai'

Then, start to write code (no matter if it's a rails application or something else):

require 'rubirai'
# assuming your mirai http api address and port
# are 127.0.0.1 and 8080
bot = Rubirai::Bot.new('127.0.0.1', '8080')
# qq and verify key
bot.login 1145141919, 'ikisugi_key'

# Add a listener function
bot.add_listener do |event|
  puts event.inspect
  if event.is_a?(Rubirai::MessageEvent)
    event.respond("Hello, world!")
  end
end

# Listen to message every 0.5 seconds
# And blocks the current thread
bot.start_listen 0.5, is_blocking: true

If you want to install globally with gem, use

gem install rubirai 

Wiki and Documentation

License

AGPL-3.0 License

FOSSA Status

About

Ruby library for mirai-api-http

https://www.rebuild.moe/rubirai

License:GNU Affero General Public License v3.0


Languages

Language:Ruby 99.3%Language:CSS 0.7%