1 class HelpPlugin < PluginBase
2 def self.cmd_help(socket, sender, isprivate, args)
4 if args.blank? or not PluginBase.has_command?(args) then
5 if not args.blank? then
6 socket.sendPrivateMessage(sender, "Unknown command '#{args}'.")
8 socket.sendPrivateMessage(sender, "Available commands are:")
9 PluginBase.commands.each do |cmd|
10 if PluginBase.has_command_help?(cmd) then
11 socket.sendPrivateMessage(sender, " #{self.command_help(cmd)}")
15 self.send_usage(socket, sender, args)
19 def self.cmd_help_help
20 [nil, "Displays this help"]
23 def self.cmd_about(socket, sender, isprivate, args)
25 I am a Direct Connect bot written in Ruby.
26 I was written by Kevin Ballard <kevin@sb.org>.
27 My code is available at http://repo.or.cz/w/dcbot.git
29 about.split("\n").each do |line|
30 socket.sendPrivateMessage(sender, line)
34 def self.cmd_about_help
35 [nil, "Displays information about this bot"]
38 def self.command_help(cmd)
39 message = "#{CMD_PREFIX}#{cmd}"
40 if PluginBase.has_command_help?(cmd) then
41 arghelp, cmdhelp = PluginBase.command_help(cmd).call()
42 message << " #{arghelp}" unless arghelp.nil? or arghelp.empty?
43 message << " - #{cmdhelp}"
48 def self.send_usage(socket, user, cmd)
49 socket.sendPrivateMessage(user, "Usage: #{self.command_help(cmd)}")