Project

General

Profile

[Script] Session Manager » sessionManager-v2.ini

Version 2 - 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 -sg Saved %chanlist
echo -sg $str($chr(160),2))to session: %sessionName
echo -sg $str($chr(160),2))for network: %net
}

alias sessMan.load {
if ($1 == $null) {
%sessionName = default
} else {
%sessionName = $1
}
%joinstring = $readini(sessMan-sessions.ini,$network,%sessionName)
if (%joinString == $null) {
if ( $2 != quiet ) {
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
}
}

on *:DISCONNECT:{
if ( $readini(sessMan-options.ini,config,autoSave) == true ) {
echo -ag Saving currently connected channels to session 'previous'
sessMan.save previous
}
}

on *:CONNECT:{
if ( $readini(sessMan-options.ini,config,autoJoin) == truedef ) {
sessMan.load default quiet
} elseif ( $readini(sessMan-options.ini,config,autoJoin) == trueprev ) {
sessMan.load previous quiet
}
}

menu channel,status {
Session Manager
.Save
..Save New:/sessMan.save
..-
..$submenu($sessMan.menuSess($1,save))
.Load
..$submenu($sessMan.menuSess($1,load))
.-
.Options
..Auto Part current channels on loading
...Enable $+ $iif($readini(sessMan-options.ini,config,autoPart) == true,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoPart true
...Disable $+ $iif($readini(sessMan-options.ini,config,autoPart) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoPart
..Auto Join Session on Connect
...Join Default $+ $iif($readini(sessMan-options.ini,config,autoJoin) == truedef,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoJoin truedef
...Join Previous $+ $iif($readini(sessMan-options.ini,config,autoJoin) == trueprev,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoJoin trueprev
...Disable $+ $iif($readini(sessMan-options.ini,config,autoJoin) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoJoin
..Auto Save 'previous' on Disconnect
...Enable $+ $iif($readini(sessMan-options.ini,config,autoSave) == true,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoSave true
...Disable $+ $iif($readini(sessMan-options.ini,config,autoSave) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoSave
..-
..Delete Session
...$submenu($sessMan.menuOpt($1,deleteSession))
}

alias sessMan.menuOpt {
if ( $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 {
if ( $2 = save ) {
return %sess $+ :sessMan.save %sess
} elseif ($2 = load ) {
return %sess $+ :sessMan.load %sess
} else {
return
}
}
}
(3-3/6)