-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_commands.rb
More file actions
47 lines (43 loc) · 1.02 KB
/
plugin_commands.rb
File metadata and controls
47 lines (43 loc) · 1.02 KB
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
37
38
39
40
41
42
43
44
45
46
47
class Commands
include Cinch::Plugin
prefix ">"
match /(.+)(?: (.+))?/i , method: :command
match /commands/ , method: :commands
#*/
def initialize(*args)
super
ObjectSpace.each_object(Team) do |teamObj|
@team = teamObj
end
@mysql = nil
ObjectSpace.each_object(Mysql) { |o|
@mysql = o
}
@commands = ["autovoice",
"join","part","quit",
"myaccess","access", "addhelper","addadmin","suspend","unsuspend",
"adduser",
"commands",
"createwebpass"
]
end
def command(m,command)
args = command.split(" ")
return if @commands.include?(args[0]) || !@team.helper(m.user)
m.user.send "command #{args[0]} is not known"
end
def commands(m)
commandos = []
m.user.send "I know the following commands:"
@commands.each do |commando|
commandos.push("#{commando}")
if commandos.length > 4
m.user.send commandos.join(", ")
commandos = []
end
end
if commandos.length>0
m.user.send commandos.join(", ")
end
end
end