#-- vim:sw=2:et #++ # # :title: Shell Plugin for RBot # # Author:: Yaohan Chen # Copyright:: (C) 2008 Yaohan Chen # License:: GPLv2 require 'treetop' Treetop.load_string < m, # so they are considered depth 1. maybe we should calculate the depth using # the command parse tree, but having the parse tree implies finite depth new_m = fake_message(s, :from => m, :delegate => false) class << new_m self end.send(:define_method, :reply) do |s| replies << s end @bot.plugins.irc_delegate('privmsg', new_m) replies.join(' ') end m.reply result end def help(plugin, topic=nil) %{The "shell" command enables interpolation of commands. For example, "shell say #channel $(ping)" will say the response of the ping command, "pong", in #channel. Note that not all output of commands are considered response, only those using m.reply. It's recommended to interpolate only commands that respond quickly.} end end plugin = ShellPlugin.new plugin.map 'shell *command'