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">
<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$/notification.rb" afterPath="$PROJECT_DIR$/notification.rb" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -15,21 +14,21 @@
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<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">
<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" />
<folding />
</state>
</provider>
</entry>
</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">
<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" />
<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>
@ -38,7 +37,7 @@
<file leaf-file-name="core.rb" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core.rb">
<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" />
<folding />
</state>
@ -269,12 +268,12 @@
<option name="presentableId" value="Default" />
<updated>1492353576138</updated>
<workItem from="1492353577745" duration="1817000" />
<workItem from="1492433677612" duration="6539000" />
<workItem from="1492433677612" duration="7006000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="8356000" />
<option name="totallyTimeSpent" value="8823000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="27" width="1920" height="1020" extended-state="6" />
@ -334,9 +333,17 @@
</state>
</provider>
</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">
<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" />
<folding />
</state>
@ -344,19 +351,11 @@
</entry>
<entry file="file://$PROJECT_DIR$/Janitor.rb">
<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" />
<folding />
</state>
</provider>
</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>
</project>

View file

@ -2,16 +2,16 @@ require 'teamspeak-ruby'
class Janitor
debug_mode = true
$ts = Teamspeak::Client.new('ts3.vereto.net')
def new
$ts = login()
@ts = Teamspeak::Client.new('ts3.vereto.net')
def initialize
@ts = login()
end
def login()
$ts.login('serveradmin', ENV["SrvQry"].dup)
$ts.command('use', {sid: 1})
return ts
@ts.login('serveradmin', ENV["SrvQry"].dup)
@ts.command('use', {sid: 1})
return @ts
end
def roll()
@ -20,41 +20,41 @@ class Janitor
def gsay(msg)
if debug_mode == true
$ts.command('sendtextmessage', {targetmode: 3, target: 1, msg: msg})
@ts.command('sendtextmessage', {targetmode: 3, target: 1, msg: msg})
else
$ts.command('sendtextmessage', {targetmode: 1, target: 13, msg: msg})
@ts.command('sendtextmessage', {targetmode: 1, target: 13, msg: msg})
end
end
def listen(global)
if global == true
return $ts.command('servernotifyregister', event: 'textserver')[0]
return @ts.command('servernotifyregister', event: 'textserver')[0]
else
move_self('218')
return $ts.command('servernotifyregister', event: 'textchannel', id: '218' )[0]
return @ts.command('servernotifyregister', event: 'textchannel', id: '218' )[0]
end
end
def get_clients()
return $ts.command('clientlist')
return @ts.command('clientlist')
end
def get_channels()
return $ts.command('channellist')
return @ts.command('channellist')
end
def find_client(name)
#//This doesnt seem to work very well
return $ts.command('clientfind', {pattern: name.to_s})
return @ts.command('clientfind', {pattern: name.to_s})
end
def whoami()
return $ts.command('whoami')
return @ts.command('whoami')
end
def move_client(clid, cid)
return $ts.command('clientmove', clid: clid, cid: cid)
return @ts.command('clientmove', clid: clid, cid: cid)
end
def move_self(cid)
@ -63,7 +63,7 @@ class Janitor
def check_channels()
server_info = $ts.command('serverinfo')
server_info = @ts.command('serverinfo')
t = server_info['virtualserver_uptime']
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 "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']
@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)
@ts.command('channeledit', cid: channel['cid'], channel_codec_quality: 9)
end
$ts.command('clientlist').each do |user|
@ts.command('clientlist').each do |user|
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 << "]"
end
end