Project

General

Profile

[Script] Session Manager » sessionManager-v1.ini

Origional - Trel Smith, 12/15/2016 04:22 PM

 
alias sessMan.save {
var %net = $network
var %i = 1
var %chanlist = $null
if ($1 == $null) {
%sessionName = $?"Session Name. (If blank, will use 'default')"
} else {
%sessionName = $1
}
if (%sessionName != $null) {

} else {
%sessionName = default
}
while (%i <= $chan(0)) {
if (%chanlist == $null) {
var %chanlist = $chan(%i)
} else {
var %chanlist = %chanlist $+ , $+ $chan(%i)
}
inc %i
}
writeini sessMan-sessions.ini %net %sessionName %chanlist
;echo -ag Saved %chanlist
;echo -ag to session: %session
;echo -ag for network: %net
}

alias sessMan.load {
if ($1 == $null) {
%sessionName = default
} else {
%sessionName = $1
}
%joinstring = $readini(sessMan-sessions.ini,$network,%sessionName)
if (%joinString == $null) {
echo -ag Session Does Not Exist
return
} else {
if ( $readini(sessMan-options.ini,config,autoPart) == true ) {
sessman.partAll
}
join %joinstring
}
}

alias sessMan.partAll {
%i = 1
while (%i <= $chan(0)) {
part $chan(%i)
inc %i
}
}

menu channel,status {
Session Manager
.Save:/sessMan.save
.Load
..$submenu($sessMan.menuSess($1))
.-
.Options
..AutoPart
...$submenu($sessMan.menuOpt($1,autoPart))
...Enable:writeini sessMan-options.ini config autoPart true
...Disable:writeini sessMan-options.ini config autoPart false
..Delete Session
...$submenu($sessMan.menuOpt($1,deleteSession))
}

alias sessMan.menuOpt {
if ($2 == autoPart ) {
if ( $1 == 1 ) {
if ( $readini(sessMan-options.ini,config,autoPart) == true ) {
return Currently Enabled:echo -ag Auto Part Is Currently Enabled
} else {
return Currently Disabled:echo -ag Auto Part Is Currently Disabled
}
}
if ( $1 == end ) {
return -
}
return
} elseif ( $2 == deleteSession ) {
if ( $1 == $null ) {
%pos = 1
} else {
%pos = $1
}
%sess = $ini(sessMan-sessions.ini,$network,%pos)
if ( %sess == $null ) {
return
} else {
return Delete %sess $+ :remini sessMan-sessions.ini $network %sess
}
} else {
return
}
}

alias sessMan.menuSess {
if ( $1 == $null ) {
%pos = 1
} else {
%pos = $1
}
%sess = $ini(sessMan-sessions.ini,$network,%pos)
if ( %sess == $null ) {
return
} else {
;My load alias handles if it needs to auto part currently joined channels
;return %sess $+ :join $readini(sessMan-sessions.ini,$network,%sess)
return %sess $+ :sessMan.load %sess
}
}
(2-2/6)