Project

General

Profile

[Script] Session Manager » sessionManager-v2.ini

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

 
1
alias sessMan.save {
2
  var %net = $network
3
  var %i = 1
4
  var %chanlist = $null
5
  
6
  if ($1 == $null) {
7
    %sessionName = $?"Session Name. (If blank, will use 'default')"
8
  } else {
9
    %sessionName = $1
10
  }
11
    
12
  if (%sessionName != $null) {
13

    
14
  } else {
15
    %sessionName = default
16
  }
17
  
18
  while (%i <= $chan(0)) {
19
    if (%chanlist == $null) {
20
      var %chanlist = $chan(%i)
21
    } else {
22
      var %chanlist = %chanlist $+ , $+ $chan(%i)
23
    }
24
    inc %i
25
  }
26
    
27
  writeini sessMan-sessions.ini %net %sessionName %chanlist
28
  echo -sg Saved %chanlist
29
  echo -sg $str($chr(160),2))to session: %sessionName
30
  echo -sg $str($chr(160),2))for network: %net
31
}
32

    
33
alias sessMan.load {
34
  if ($1 == $null) {
35
    %sessionName = default
36
  } else {
37
      %sessionName = $1
38
  }
39
  
40
  %joinstring = $readini(sessMan-sessions.ini,$network,%sessionName)
41
  if (%joinString == $null) {
42
    if ( $2 != quiet ) {
43
      echo -ag Session Does Not Exist
44
    }
45
    return
46
  } else {
47
    if ( $readini(sessMan-options.ini,config,autoPart) == true ) {
48
      sessman.partAll
49
    }
50
    join %joinstring
51
  }
52
}
53

    
54
alias sessMan.partAll {
55
  %i = 1
56
  while (%i <= $chan(0)) {
57
    part $chan(%i)
58
    inc %i
59
  }
60
}
61

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

    
69
on *:CONNECT:{
70
  if ( $readini(sessMan-options.ini,config,autoJoin) == truedef ) {
71
    sessMan.load default quiet
72
  } elseif ( $readini(sessMan-options.ini,config,autoJoin) == trueprev ) {
73
    sessMan.load previous quiet
74
  }
75
}
76

    
77
menu channel,status {
78
  Session Manager
79
    .Save
80
    ..Save New:/sessMan.save
81
    ..-
82
    ..$submenu($sessMan.menuSess($1,save))
83
    .Load
84
    ..$submenu($sessMan.menuSess($1,load))
85
    .-
86
    .Options
87
    ..Auto Part current channels on loading
88
    ...Enable $+ $iif($readini(sessMan-options.ini,config,autoPart) == true,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoPart true
89
    ...Disable $+ $iif($readini(sessMan-options.ini,config,autoPart) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoPart
90
    ..Auto Join Session on Connect
91
    ...Join Default $+ $iif($readini(sessMan-options.ini,config,autoJoin) == truedef,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoJoin truedef
92
    ...Join Previous $+ $iif($readini(sessMan-options.ini,config,autoJoin) == trueprev,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoJoin trueprev
93
    ...Disable $+ $iif($readini(sessMan-options.ini,config,autoJoin) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoJoin
94
    ..Auto Save 'previous' on Disconnect
95
    ...Enable $+ $iif($readini(sessMan-options.ini,config,autoSave) == true,$chr(160) $+ (Selected), ):writeini sessMan-options.ini config autoSave true
96
    ...Disable $+ $iif($readini(sessMan-options.ini,config,autoSave) == $null,$chr(160) $+ (Selected), ):remini sessMan-options.ini config autoSave
97
    ..-
98
    ..Delete Session
99
    ...$submenu($sessMan.menuOpt($1,deleteSession))
100
}
101

    
102
alias sessMan.menuOpt {
103
  if ( $2 == deleteSession ) {
104
    if ( $1 == $null ) {
105
      %pos = 1
106
    } else {
107
      %pos = $1
108
    }
109
    
110
    %sess = $ini(sessMan-sessions.ini,$network,%pos)
111
     if ( %sess == $null ) {
112
       return
113
     } else {
114
       return Delete %sess $+ :remini sessMan-sessions.ini $network %sess
115
     }
116
  } else {
117
    return
118
  }
119
}
120

    
121
alias sessMan.menuSess {
122
  if ( $1 == $null ) {
123
    %pos = 1
124
  } else {
125
    %pos = $1
126
  }
127
  
128
  %sess = $ini(sessMan-sessions.ini,$network,%pos)
129
  if ( %sess == $null ) {
130
    return
131
  } else {
132
    if ( $2 = save ) {
133
      return %sess $+ :sessMan.save %sess
134
    } elseif ($2 = load ) {
135
      return %sess $+ :sessMan.load %sess
136
    } else {
137
      return
138
    }
139
  }
140
}
(3-3/6)