Add command help

This commit is contained in:
Matthias Schiffer 2013-01-02 01:13:29 +01:00
parent 09e925d695
commit dceabdbb7e
6 changed files with 68 additions and 11 deletions

View file

@ -10,7 +10,13 @@ module Lain
return unless message.type == :groupchat
return unless /!credits\b/ =~ message.body
muc.send(Jabber::Message.new(message.to, "Lain (レイン) #{Version}\n\n -- hacked by NeoRaider"))
muc.send(Jabber::Message.new(message.to, "\nLain (レイン) #{Version}\n\n -- hacked by NeoRaider"))
end
def commands
{
'!credits' => 'show credits'
}
end
end
end

View file

@ -9,7 +9,13 @@ module Lain
return unless message.type == :groupchat
return unless /!ddate\b/ =~ message.body
muc.send(Jabber::Message.new(message.to, IO.popen("ddate").gets(sep=nil).chomp))
muc.send(Jabber::Message.new(message.to, IO.popen("ddate").read.chomp))
end
def commands
{
'!ddate' => 'show Discordian date'
}
end
end
end

View file

@ -9,7 +9,13 @@ module Lain
return unless message.type == :groupchat
return unless /!fortune\b/ =~ message.body
muc.send(Jabber::Message.new(message.to, IO.popen(@config['command']).gets(sep=nil).chomp))
muc.send(Jabber::Message.new(message.to, "\n" + IO.popen(@config['command']).read.chomp))
end
def commands
{
'!fortune' => 'fortune cookies'
}
end
end
end

22
modules/Help.rb Normal file
View file

@ -0,0 +1,22 @@
require 'xmpp4r/message'
require_relative '../module_base'
module Lain
module Modules
class Help < Base
def on_message(muc, message)
return unless message.type == :groupchat
return unless /!help\b/ =~ message.body
muc.send(Jabber::Message.new(message.to, "Commands:" + @lain.commands.reduce('') { |s, cmd| "#{s}\n#{cmd[0]}: #{cmd[1]}" }))
end
def commands
{
'!help' => 'show this help'
}
end
end
end
end