menu channel,status { Session Manager .Save ..Save New:/sessMan.save ..- ..$submenu($sessMan.menu.save($1)) .Load ..$submenu($sessMan.menu.load($1)) } menu channel { ;By separating it into three parts, ;I don't have to use those $iif bits that seem to break mIRC or AdiIRC depending on which way I do it Session Manager ..$submenu($sessMan.menu.load($1)) .Add $chan To Existing ..$submenu($sessMan.menu.append($1)) .Remove $chan From Existing ..$submenu($sessMan.menu.detach($1)) } menu channel,status { Session Manager .- .Options ..Auto Part current channels on loading ...$iif($readini(sessMan-options.ini,config,autoPart) == true,$style(1),$null) $+ Enable:writeini sessMan-options.ini config autoPart true ...$iif($readini(sessMan-options.ini,config,autoPart) == $null,$style(1),$null) $+ Disable:remini sessMan-options.ini config autoPart ..Auto Join Session on Connect ...$iif($readini(sessMan-options.ini,config,autoJoin) == truedef,$style(1),$null) $+ Join Default:writeini sessMan-options.ini config autoJoin truedef ...$iif($readini(sessMan-options.ini,config,autoJoin) == trueprev,$style(1),$null) $+ Join Previous:writeini sessMan-options.ini config autoJoin trueprev ...$iif($readini(sessMan-options.ini,config,autoJoin) == $null,$style(1),$null) $+ Disable:remini sessMan-options.ini config autoJoin ..Auto Save 'previous' on Disconnect ...$iif($readini(sessMan-options.ini,config,autoSave) == true,$style(1),$null) $+ Enable:writeini sessMan-options.ini config autoSave true ...$iif($readini(sessMan-options.ini,config,autoSave) == $null,$style(1),$null) $+ Disable:remini sessMan-options.ini config autoSave ..- ..Delete Session ...$submenu($sessMan.menu.delete($1)) } 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 } } alias sessMan.save { var %i = 1 var %chanlist = $null if ($1 == $null) { %sessionName = $?"Session Name. (If blank, will use 'default')" } else { %sessionName = $1 } if (%sessionName == $null) { %sessionName = default } while (%i <= $chan(0)) { ; ; Turns out using tokens makes this a one liner without needing an if at all ; Who knew? (Apparently everyone who knows AdiIRC/mIRC scripting) ; %chanlist = $addtok(%chanlist,$chan(%i),44) inc %i } if ( %chanlist != $null ) { writeini sessMan-sessions.ini $network %sessionName %chanlist echo -ag Saved %chanlist echo -ag $str($chr(160),2) to session: %sessionName echo -ag $str($chr(160),2) for network: $network } } alias sessMan.load { if ($1 == $null) { %sessionName = default } else { %sessionName = $1 } %chanlist = $readini(sessMan-sessions.ini,$network,%sessionName) if (%chanlist == $null) { if ( $2 != quiet ) { echo -ag Session Does Not Exist } return } else { if ( $readini(sessMan-options.ini,config,autoPart) == true ) { sessman.partAll } join %chanlist } } alias sessMan.append { if ( $1 == $null ) return var %session = $1 var %chanlist = $readini(sessMan-sessions.ini,$network,%session) if ( %chanlist == $null ) { return } var %chanlist = $addtok(%chanlist,$chan,44) writeini sessMan-sessions.ini $network %session %chanlist } alias sessMan.detach { if ( $1 == $null || $2 == $null ) return var %sess = $1 var %chan = $2 $+ ,? var %chanlist = $readini(sessMan-sessions.ini,$network,%sess) noop $regsub(detach,%chanlist,/ $+ %chan $+ /g,,%newchanlist) if (%newchanlist == $null) { echo -ag That was the only channel in the session echo -ag Deleting the session instead remini sessMan-sessions.ini $network %sess return } writeini sessMan-sessions.ini $network %sess %newchanlist echo -ag Channel: $2 removed from Session: %sess } alias sessMan.partAll { var %i = 1 while (%i <= $chan(0)) { part $chan(%i) inc %i } } alias sessMan.menu.save { var %pos = $sessMan.func.menupos($1) var %sess = $ini(sessMan-sessions.ini,$network,%pos) ;This bit isn't stricly needed because it seems to immediately return null if the return STARTS with null. ;However, if there's text first, it will loop indefinitely since it will never return null, so I will include this anyway to be safe. ;Basically if I was just returning the variable, it would work right without the forced return on null. if ( %sess == $null ) return return %sess $+ :sessMan.save %sess } alias sessMan.menu.load { var %pos = $sessMan.func.menupos($1) %sess = $ini(sessMan-sessions.ini,$network,%pos) ;This bit isn't stricly needed because it seems to immediately return null if the return STARTS with null. ;However, if there's text first, it will loop indefinitely since it will never return null, so I will include this anyway to be safe. ;Basically if I was just returning the variable, it would work right without the forced return on null. if ( %sess == $null ) return return %sess $+ :sessMan.load %sess } alias sessMan.menu.delete { var %pos = $sessMan.func.menupos($1) var %sess = $ini(sessMan-sessions.ini,$network,%pos) ;See the comment in save and load for an explanation on why this line is here if ( %sess == $null ) return return Delete %sess $+ :remini sessMan-sessions.ini $network %sess } alias sessMan.menu.append { var %pos = $sessMan.func.menupos($1) var %sess = $ini(sessMan-sessions.ini,$network,%pos) ;See the comment in save and load for an explanation on why this line is here if ( %sess == $null ) return return Add To %sess $+ :sessMan.append %sess } alias sessMan.menu.detach { if ( $1 == begin ) { %i = 1 %count = $ini(sessMan-sessions.ini,$network,0) while (%i <= %count) { %position = $ini(sessMan-sessions.ini,$network,%i) if ($pos($readini(sessMan-sessions.ini,$network,%position),$chan,0) == 1) { writeini sessMan-temp.ini menuGen $ini(sessMan-sessions.ini,$network,%i) 1 } inc %i } } if ( $1 == end ) { remini sessMan-temp.ini menuGen } var %pos = $sessMan.func.menupos($1) var %sess = $ini(sessMan-temp.ini,menuGen,%pos) ;See the comment in save and load for an explanation on why this line is here if ( %sess == $null ) return return Remove $chan from %sess :sessMan.detach %sess $chan } alias sessMan.func.menupos { ;This is because for menus, I need it to not return null for 'begin' and 'end' if ( $1 == $null ) { return 1 } else { return $1 } } alias sessMan.func.menuini { ;This doesn't do anything because it was stupid ;Seriously, the line to load the ini is one line long ;It doesn't make sense to make it a function when the function call would ALSO be one line ;Go away, it's like fetch, it's never going to happen }