Leave server implementations to determine commands

master
Marrub 2017-08-06 19:30:24 -04:00
parent 9a7512c7c3
commit 51c9d0fdd5
3 changed files with 11 additions and 17 deletions

View File

@ -6,8 +6,8 @@ class Mod_Util < Vrobot4::Module::Module
register :testf, "Test function."
end
def testf msg, argv
puts "test function run", msg, argv
def testf m, argv
puts "test function run", m, argv
end
end

View File

@ -7,8 +7,8 @@ module Vrobot4::Module
@help_str = help
end
def run msg, argv
@function.call(msg, argv)
def run m, argv
@function.call(m, argv)
end
end
@ -25,8 +25,8 @@ module Vrobot4::Module
@commands.each {|cmd| yield cmd}
end
def onCommand msg, cmdname, argv
@commands[cmdname].run(msg, argv) if @commands.has_key? cmdname
def onCommand m, cnam, argv
@commands[cnam].run(m, argv) if @commands.has_key? cnam
end
end

View File

@ -8,10 +8,6 @@ module Vrobot4::Server
def initialize msg
@msg = msg
end
def to_s
@msg
end
end
class Channel
@ -26,15 +22,13 @@ module Vrobot4::Server
@modules << mod
end
def onMessage msg
if msg.start_with? '.'
onCommand msg, nil, nil
end
log :MSG, msg.to_s
def onMessage m
Vrobot4.log :DEBUG, "message:", m.to_s
end
def onCommand msg, cmdname, argv
@modules.each {|mod| mod.onCommand msg, cmdname, argv}
def onCommand m, cnam, argv
Vrobot4.log :DEBUG, "command:", m.to_s, cnam.to_s, argv.to_s
@modules.each {|mod| mod.onCommand m, cnam, argv}
end
end