require 'teamspeak-ruby' class Janitor def initialize @ts = login() @global = false end def login() @ts = Teamspeak::Client.new('ts3.vereto.net') @ts.login('serveradmin', ENV["SrvQry"].dup) @ts.command('use', {sid: 1}) @ts.command('clientupdate', client_nickname: '[BOT]\sJanitor') return @ts end def roll() return 1 + rand(6) end def gsay(msg) if @global == true @ts.command('sendtextmessage', {targetmode: 3, target: 1, msg: msg}) else @ts.command('sendtextmessage', {targetmode: 2, target: whoami['client_channel_id'], msg: msg}) end end def listen() if @global == true return @ts.command('servernotifyregister', event: 'textserver')[0] else return @ts.command('servernotifyregister', event: 'textchannel', id: 218 )[0] end end def get_clients() return @ts.command('clientlist') end def get_channels() return @ts.command('channellist') end def find_client(name) #//This doesnt seem to work very well return @ts.command('clientfind', {pattern: name.to_s}) end def whoami() return @ts.command('whoami') end def move_client(clid, cid) return @ts.command('clientmove', clid: clid, cid: cid) end def move_self(cid) return move_client(whoami['client_id'], cid) end def check_channels() server_info = @ts.command('serverinfo') t = server_info['virtualserver_uptime'] mm, ss = t.divmod(60) #=> [4515, 21] hh, mm = mm.divmod(60) #=> [75, 15] dd, hh = hh.divmod(24) #=> [3, 3] puts "Server has been online for: %d days, %d hours, %d minutes and %d seconds" % [dd, hh, mm, ss] puts "Clients Online: " + server_info['virtualserver_clientsonline'].to_s @ts.command('channellist').each do |channel| channel_quality = @ts.command('channelinfo', cid: channel['cid'])['channel_codec_quality'] puts "(" << channel['cid'].to_s << ")" << channel['channel_name'] << "| [Codec] " << channel_quality.to_s if channel_quality != 9 puts "Needs set!" @ts.command('channeledit', cid: channel['cid'], channel_codec_quality: 9) end @ts.command('clientlist').each do |user| if user['cid'] == channel['cid'] server_groups = @ts.command('servergroupsbyclientid', cldbid: user['client_database_id']) puts "--------" << user['client_nickname'] << "(" << user['clid'].to_s << ")" << "[" << server_groups[0]["name"].to_s << "]" end end end end end