Class: Cinch::BotTemplate::Templates::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/bot_template/templates/plugin.rb

Class Method Summary collapse

Class Method Details

.generate(plugin_names:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cinch/bot_template/templates/plugin.rb', line 7

def Plugin.generate(plugin_names:)
  plugins = {}
  plugin_names.each do |plugin|
    name = "#{plugin.capitalize}Plugin"

    bot = <<~BOT
    class #{name}
      include Cinch::Plugin
      match /^hello$/, method: :hello_world
      # @param [Cinch::Message] m cinch message object
      def hello_world(m)
        m.reply "Hello \#{m.user.nick}"
      end
    end
    BOT
    plugins[plugin+'.rb'] = bot

  end
  plugins
end