class Commands_manager

Public Class Methods

new() click to toggle source
# File lib/rirc.rb, line 790
def initialize
        @reg_s = []
        @hook_s = []
        @size = 0
        @log_path = "./.log"
        @err_path = "./.errlog"
end

Public Instance Methods

check_cmds(ircbot, msg, pluginmgr) click to toggle source
# File lib/rirc.rb, line 814
def check_cmds(ircbot, msg, pluginmgr)

        if @size == 0
                return
        end

        0.upto(@size - 1) do |i|
                if msg.message_regex(@reg_s[i])
                        File.write(@log_path, msg, File.size(@log_path), mode: 'a')
                        begin
                                @hook_s[i].call(ircbot, msg, pluginmgr)
                        rescue => e
                                if File.exist?(@err_path)
                                        File.write(@err_path, "COMMAND FAILED TO EXECUTE", File.size(@err_path), mode: 'a')
                                        File.write(@err_path, "======================================================", File.size(@err_path), mode: 'a')
                                        File.write(@err_path, e.to_s, File.size(@err_path), mode: 'a')
                                        File.write(@err_path, e.backtrace.to_s, File.size(@err_path), mode: 'a')
                                        File.write(@err_path, "======================================================", File.size(@err_path), mode: 'a')
                                end
                        end
                end
        end
end
hooks() click to toggle source
# File lib/rirc.rb, line 838
def hooks
        return @hook_s
end
on(reg, &block) click to toggle source

def initialize(log_path, err_path)

@reg_s = []
@hook_s = []
@size = 0
@log_path = log_path
@err_path = err_path

end

# File lib/rirc.rb, line 807
def on(reg, &block)
      reg = Regexp.new(reg.to_s)
      @reg_s.push(reg)
      @hook_s << block
      @size += 1
end
regs() click to toggle source
# File lib/rirc.rb, line 842
def regs
        return @reg_s
end
size() click to toggle source
# File lib/rirc.rb, line 846
def size
        return @size
end