Messing with scope

This commit is contained in:
promostarr 2017-04-17 15:51:36 +01:00
parent 4cdee5c61f
commit abf5b9b684
2 changed files with 39 additions and 40 deletions

35
.idea/workspace.xml generated
View file

@ -3,7 +3,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="ecb21532-0ae7-441d-90a8-4b144fd51290" name="Default" comment=""> <list default="true" id="ecb21532-0ae7-441d-90a8-4b144fd51290" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Janitor.rb" afterPath="$PROJECT_DIR$/Janitor.rb" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Janitor.rb" afterPath="$PROJECT_DIR$/Janitor.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/notification.rb" afterPath="$PROJECT_DIR$/notification.rb" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
@ -15,21 +14,21 @@
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" /> <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Janitor.rb" pinned="false" current-in-tab="false"> <file leaf-file-name="Janitor.rb" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Janitor.rb"> <entry file="file://$PROJECT_DIR$/Janitor.rb">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="769"> <state relative-caret-position="1720">
<caret line="86" column="29" lean-forward="false" selection-start-line="86" selection-start-column="29" selection-end-line="86" selection-end-column="29" /> <caret line="86" column="29" lean-forward="false" selection-start-line="86" selection-start-column="29" selection-end-line="86" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="notification.rb" pinned="false" current-in-tab="true"> <file leaf-file-name="notification.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/notification.rb"> <entry file="file://$PROJECT_DIR$/notification.rb">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="100"> <state relative-caret-position="100">
<caret line="5" column="4" lean-forward="true" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" /> <caret line="5" column="5" lean-forward="false" selection-start-line="5" selection-start-column="2" selection-end-line="5" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -38,7 +37,7 @@
<file leaf-file-name="core.rb" pinned="false" current-in-tab="false"> <file leaf-file-name="core.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core.rb"> <entry file="file://$PROJECT_DIR$/core.rb">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="640"> <state relative-caret-position="460">
<caret line="32" column="14" lean-forward="false" selection-start-line="32" selection-start-column="14" selection-end-line="32" selection-end-column="14" /> <caret line="32" column="14" lean-forward="false" selection-start-line="32" selection-start-column="14" selection-end-line="32" selection-end-column="14" />
<folding /> <folding />
</state> </state>
@ -269,12 +268,12 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1492353576138</updated> <updated>1492353576138</updated>
<workItem from="1492353577745" duration="1817000" /> <workItem from="1492353577745" duration="1817000" />
<workItem from="1492433677612" duration="6539000" /> <workItem from="1492433677612" duration="7006000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="8356000" /> <option name="totallyTimeSpent" value="8823000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="27" width="1920" height="1020" extended-state="6" /> <frame x="0" y="27" width="1920" height="1020" extended-state="6" />
@ -334,9 +333,17 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/notification.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="100">
<caret line="5" column="5" lean-forward="false" selection-start-line="5" selection-start-column="2" selection-end-line="5" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core.rb"> <entry file="file://$PROJECT_DIR$/core.rb">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="640"> <state relative-caret-position="460">
<caret line="32" column="14" lean-forward="false" selection-start-line="32" selection-start-column="14" selection-end-line="32" selection-end-column="14" /> <caret line="32" column="14" lean-forward="false" selection-start-line="32" selection-start-column="14" selection-end-line="32" selection-end-column="14" />
<folding /> <folding />
</state> </state>
@ -344,19 +351,11 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/Janitor.rb"> <entry file="file://$PROJECT_DIR$/Janitor.rb">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="769"> <state relative-caret-position="1720">
<caret line="86" column="29" lean-forward="false" selection-start-line="86" selection-start-column="29" selection-end-line="86" selection-end-column="29" /> <caret line="86" column="29" lean-forward="false" selection-start-line="86" selection-start-column="29" selection-end-line="86" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/notification.rb">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="100">
<caret line="5" column="4" lean-forward="true" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</component> </component>
</project> </project>

View file

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