Project

General

Profile

[Script] Session Manager » sessionManager-v2.0.1.ini

Trel Smith, 12/15/2016 06:42 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
  if ( %chanlist != $null ) {
28
    writeini sessMan-sessions.ini %net %sessionName %chanlist
29
    echo -sg Saved %chanlist
30
    echo -sg $str($chr(160),2))to session: %sessionName
31
    echo -sg $str($chr(160),2))for network: %net
32
  }
33
}
34

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

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

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

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

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

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

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