8 def self.inherited(subclass)
12 def self.cmd_prefix=(new_prefix)
13 CMD_PREFIX.replace(new_prefix)
17 @@plugins.map { |plugin| plugin.methods.grep(/^cmd_[a-zA-Z]+$/).map { |cmd| cmd.sub(/^cmd_/, "") } }.flatten
20 def self.has_command?(cmd)
21 self.commands.include? cmd
24 def self.has_command_help?(cmd)
25 @@plugins.any? { |plugin| plugin.methods.include? "cmd_#{cmd}_help"}
28 def self.command_help(cmd)
29 @@plugins.each do |plugin|
30 meth = plugin.methods.grep("cmd_#{cmd}_help").first
31 return plugin.method(meth) unless meth.nil?
35 def self.dispatch(socket, cmd, sender, isprivate, args)
36 @@plugins.each do |plugin|
37 if plugin.methods.include? "cmd_#{cmd}" then
39 plugin.method("cmd_#{cmd}").call(socket, sender, isprivate, args)
40 rescue StandardError => e
41 STDERR.puts "Exception raised executing cmd_#{cmd}:\n#{e.to_s}"
43 socket.sendPrivateMessage(sender, "An error occurred executing your command. Retrying...")
45 plugin.method("cmd_#{cmd}").call(socket, sender, isprivate, args)
53 @@pluginWrapper = Module.new
54 Dir["plugins/*"].each do |file|
56 @@pluginWrapper.class_eval File.read(file), file
57 rescue StandardError, ScriptError => e
58 STDERR.puts "Error loading plugin `#{file}': #{e.to_s}"
64 ActiveRecord::Base.establish_connection(
68 :database => "40thieves")
73 PluginBase.loadPlugins