No commit activity in last 3 years
No release in over 3 years
ruboty-generator generate ruboty plugin template.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 2.14.1

Runtime

~> 0.18.1
 Project Readme

Ruboty::Gen::Readme

Generate Ruboty Handler + Actions plugin.

Gem Version Build Status

Ruboty is Chat bot framework. Ruby + Bot = Ruboty

⬇️ Installation

Add this line to your application's Gemfile:

gem 'ruboty-generator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruboty-generator

📘 Rubotygenerator

Setting File Parameters

key value example
user_name github user name tbpgr
gem_class_name gem class name Hoge
gem_name gem name hoge
description description An Ruboty Handler + Actions to output hige.
env/name ENV variable name DEFAULT_HOGE_TEXT
env/description ENV description default hoge text
commands/command name Ruboty::Handler.on name hoge
commands/command pattern Ruboty::Handler.on pattern /hoge\z/
commands/command description Ruboty::Handler.on description output hige

📜 Usage

init

generate Rubotygenerator template file.

$ ruboty-generator init
$ ls -1 | grep Rubotygenerator
Rubotygenerator

generate

generate Ruboty Handler + Action template

  • edit Rubotygenerator file
# encoding: utf-8
user_name "tbpgr"

gem_class_name "Hoge"
gem_name "hoge"

description "An Ruboty Handler + Actions to hoge-hige"

env do |e|
  e.name "DEFAULT_HOGE_TEXT1"
  e.description "DEFAULT_HOGE_TEXT1 desc"
end

env do |e|
  e.name "DEFAULT_HOGE_TEXT2"
  e.description "DEFAULT_HOGE_TEXT2 desc"
end

command do |c|
  c.name "hoge"
  c.pattern "hoge\\z"
  c.description "output hoge"
end

command do |c|
  c.name "hige"
  c.pattern "hige\\z"
  c.description "output hige"
end

generate plugin with action

$ ruboty-generator generate -a
  • output
.
└── ruboty-hoge
    ├── Gemfile
    ├── LICENSE.txt
    ├── README.md
    ├── Rakefile
    ├── bin
    │   ├── console
    │   └── setup
    ├── lib
    │   └── ruboty
    │       ├── handlers
    │       │   └── hoge.rb
    │       ├── hoge
    │       │   ├── actions
    │       │   │   ├── hige.rb
    │       │   │   └── hoge.rb
    │       │   └── version.rb
    │       └── hoge.rb
    └── ruboty-hoge.gemspec
  • check generated handler
require "ruboty/hoge/actions/hoge"
require "ruboty/hoge/actions/hige"

module Ruboty
  module Handlers
    # An Ruboty Handler + Actions to hoge-hige
    class Hoge < Base
      on /hoge\z/, name: 'hoge', description: 'output hoge'
      on /hige\z/, name: 'hige', description: 'output hige'
      env :DEFAULT_HOGE_TEXT1, "DEFAULT_HOGE_TEXT1 desc"
      env :DEFAULT_HOGE_TEXT2, "DEFAULT_HOGE_TEXT2 desc"

      def hoge(message)
        Ruboty::Hoge::Actions::Hoge.new(message).call
      end

      def hige(message)
        Ruboty::Hoge::Actions::Hige.new(message).call
      end

    end
  end
end
  • check generated action

hoge.rb

module Ruboty
  module Hoge
    module Actions
      class Hoge < Ruboty::Actions::Base
        def call
          message.reply(hoge)
        rescue => e
          message.reply(e.message)
        end

        private
        def hoge
          # TODO: main logic
        end
      end
    end
  end
end

hige.rb

module Ruboty
  module Hoge
    module Actions
      class Hige < Ruboty::Actions::Base
        def call
          message.reply(hige)
        rescue => e
          message.reply(e.message)
        end

        private
        def hige
          # TODO: main logic
        end
      end
    end
  end
end

generate plugin without action

$ ruboty-generator generate
  • output
.
└── ruboty-hoge
    ├── Gemfile
    ├── README.md
    ├── Rakefile
    ├── bin
    │   ├── console
    │   └── setup
    ├── lib
    │   └── ruboty
    │       ├── handlers
    │       │   └── hoge.rb
    │       ├── hoge
    │       │   └── version.rb
    │       └── hoge.rb
    └── ruboty-hoge.gemspec
  • check generated handler
module Ruboty
  module Handlers
    # An Ruboty Handler + Actions to hoge-hige
    class Hoge < Base
      on /hoge\z/, name: 'hoge', description: 'output hoge'
      on /hige\z/, name: 'hige', description: 'output hige'
      env :DEFAULT_HOGE_TEXT1, "DEFAULT_HOGE_TEXT1 desc"
      env :DEFAULT_HOGE_TEXT2, "DEFAULT_HOGE_TEXT2 desc"

      def hoge(message)
        # TODO: implement your action
      end

      def hige(message)
        # TODO: implement your action
      end

    end
  end
end

👬 Contributing 👭

  1. Fork it ( https://github.com/tbpgr/ruboty-generator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request