Leave server implementations to determine commands
parent
9a7512c7c3
commit
51c9d0fdd5
|
@ -6,8 +6,8 @@ class Mod_Util < Vrobot4::Module::Module
|
||||||
register :testf, "Test function."
|
register :testf, "Test function."
|
||||||
end
|
end
|
||||||
|
|
||||||
def testf msg, argv
|
def testf m, argv
|
||||||
puts "test function run", msg, argv
|
puts "test function run", m, argv
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ module Vrobot4::Module
|
||||||
@help_str = help
|
@help_str = help
|
||||||
end
|
end
|
||||||
|
|
||||||
def run msg, argv
|
def run m, argv
|
||||||
@function.call(msg, argv)
|
@function.call(m, argv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ module Vrobot4::Module
|
||||||
@commands.each {|cmd| yield cmd}
|
@commands.each {|cmd| yield cmd}
|
||||||
end
|
end
|
||||||
|
|
||||||
def onCommand msg, cmdname, argv
|
def onCommand m, cnam, argv
|
||||||
@commands[cmdname].run(msg, argv) if @commands.has_key? cmdname
|
@commands[cnam].run(m, argv) if @commands.has_key? cnam
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,6 @@ module Vrobot4::Server
|
||||||
def initialize msg
|
def initialize msg
|
||||||
@msg = msg
|
@msg = msg
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
|
||||||
@msg
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Channel
|
class Channel
|
||||||
|
@ -26,15 +22,13 @@ module Vrobot4::Server
|
||||||
@modules << mod
|
@modules << mod
|
||||||
end
|
end
|
||||||
|
|
||||||
def onMessage msg
|
def onMessage m
|
||||||
if msg.start_with? '.'
|
Vrobot4.log :DEBUG, "message:", m.to_s
|
||||||
onCommand msg, nil, nil
|
|
||||||
end
|
|
||||||
log :MSG, msg.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def onCommand msg, cmdname, argv
|
def onCommand m, cnam, argv
|
||||||
@modules.each {|mod| mod.onCommand msg, cmdname, argv}
|
Vrobot4.log :DEBUG, "command:", m.to_s, cnam.to_s, argv.to_s
|
||||||
|
@modules.each {|mod| mod.onCommand m, cnam, argv}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue