diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/Credits.rb | 8 | ||||
-rw-r--r-- | modules/DDate.rb | 8 | ||||
-rw-r--r-- | modules/Fortune.rb | 8 | ||||
-rw-r--r-- | modules/Help.rb | 22 |
4 files changed, 43 insertions, 3 deletions
diff --git a/modules/Credits.rb b/modules/Credits.rb index e0289e4..190c284 100644 --- a/modules/Credits.rb +++ b/modules/Credits.rb @@ -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 diff --git a/modules/DDate.rb b/modules/DDate.rb index af9912e..3c9f3e1 100644 --- a/modules/DDate.rb +++ b/modules/DDate.rb @@ -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 diff --git a/modules/Fortune.rb b/modules/Fortune.rb index 2b9d63b..f8b237a 100644 --- a/modules/Fortune.rb +++ b/modules/Fortune.rb @@ -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 diff --git a/modules/Help.rb b/modules/Help.rb new file mode 100644 index 0000000..84d9a9e --- /dev/null +++ b/modules/Help.rb @@ -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 |