forked from gsathya/Polkabot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.rb
36 lines (31 loc) · 963 Bytes
/
help.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Help
include Cinch::Plugin
plugin "help"
help "!help [name] - Get information about a command (or all commands with no name). Ex - !help"
match /h(?:elp)? (.+)/, method: :with_name
def with_name(m, query)
result = @bot.plugins.find do |plugin|
help_message = plugin.class.instance_variable_get(:@__cinch_help_message)
name = plugin.class.instance_variable_get(:@__cinch_name)
if (help_message && name == query)
return help_message
end
end
if result
m.reply "#{result}"
else
m.reply "Sorry, no help found for #{query}."
end
end
match /h(?:elp)?$/, method: :without_name
def without_name(m)
@bot.plugins.each do |plugin|
help_message = plugin.class.instance_variable_get(:@__cinch_help_message)
if help_message
name = plugin.class.instance_variable_get(:@__cinch_name)
m.reply "#{help_message}"
end
sleep(0.3)
end
end
end