1 task :plugin, :name do |t, args|
4 Usage: rake #{t}[<plugin name>]
5 Example: rake plugin[Greet]
8 plugin_name = args.name.downcase
9 class_name = "#{plugin_name.capitalize}Plugin"
10 plugin_template = <<-eot
11 class #{class_name} < Plugin
12 def help(plugin, topic="")
17 _("hello, this is an example topic of my new plugin! :)")
19 _("#{plugin_name} plugin — topics: %{list}") % {
20 :list => topics.join(", ")
25 def example(m, params)
26 m.reply "example action was triggered"
30 plugin = #{class_name}.new
31 plugin.map "#{plugin_name} [:arg]", :action => 'example'
34 plugins_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data/rbot/plugins'))
35 file_path = File.join(plugins_path, "#{plugin_name}.rb")
37 if File.exist?(file_path)
38 puts "File exists: #{file_path}"
40 input = STDIN.gets.chomp
43 exit unless input =~ /y(es)?/
46 File.open(file_path, "w") do |f|
50 puts "Plugin skeleton for #{class_name} written to #{file_path}!"
51 puts "Now issue `rescan` on the bot and use the command `help #{plugin_name}` to see that the plugin works."