summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-01-02 01:13:29 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-01-02 01:13:29 +0100
commitdceabdbb7ede39694ecac9e71b36124e4123e741 (patch)
tree9fbab4f2f8971baa741521cf6e7ad70b267f0ba4 /modules
parent09e925d6956cd7431a3466d8b659a7207e029617 (diff)
downloadlain-dceabdbb7ede39694ecac9e71b36124e4123e741.tar
lain-dceabdbb7ede39694ecac9e71b36124e4123e741.zip
Add command help
Diffstat (limited to 'modules')
-rw-r--r--modules/Credits.rb8
-rw-r--r--modules/DDate.rb8
-rw-r--r--modules/Fortune.rb8
-rw-r--r--modules/Help.rb22
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