-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_test.rb
More file actions
executable file
·50 lines (44 loc) · 941 Bytes
/
plugin_test.rb
File metadata and controls
executable file
·50 lines (44 loc) · 941 Bytes
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
48
49
50
class Test
include Cinch::Plugin
prefix ">"
match /mysqlTest/, method: :mysqlTest
match /mysqlqry(?: (.+))?/, method: :mysqlQry
def initialize(*args)
super
@mysql = nil
ObjectSpace.each_object(Mysql) { |o|
@mysql = o
}
@team = nil
ObjectSpace.each_object(Team) do |teamObj|
@team = teamObj
end
end
def mysqlTest(m)
return unless @team.helper(m.user)
if @mysql.nil?
ObjectSpace.each_object(Mysql) { |o|
@mysql = o
}
end
m.reply "Test:"
m.reply @mysql::get_server_version()
end
def mysqlQry(m,qry)
return unless @team.admin(m.user)
if @mysql.nil?
ObjectSpace.each_object(Mysql) { |o|
@mysql = o
}
end
qry ||= "SELECT * FROM `rubyTest`.`team`"
result = @mysql::query(qry)
result.each_hash do |ret|
text = ""
ret.each do |name,value|
text << "#{name}: #{value} "
end
m.reply text
end
end
end