Project

General

Profile

[Script] Session Manager » sessionManager-v1.ini

Origional - 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 -ag Saved %chanlist
29
  ;echo -ag   to session: %session
30
  ;echo -ag   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
    echo -ag Session Does Not Exist
43
    return
44
  } else {
45
    if ( $readini(sessMan-options.ini,config,autoPart) == true ) {
46
      sessman.partAll
47
    }
48
    join %joinstring
49
  }
50
}
51

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

    
60
menu channel,status {
61
  Session Manager
62
    .Save:/sessMan.save
63
    .Load
64
    ..$submenu($sessMan.menuSess($1))
65
    .-
66
    .Options
67
    ..AutoPart
68
    ...$submenu($sessMan.menuOpt($1,autoPart))
69
    ...Enable:writeini sessMan-options.ini config autoPart true
70
    ...Disable:writeini sessMan-options.ini config autoPart false
71
    ..Delete Session
72
    ...$submenu($sessMan.menuOpt($1,deleteSession))
73
}
74

    
75
alias sessMan.menuOpt {
76
  if ($2 == autoPart ) {
77
    if ( $1 == 1 ) {
78
      if ( $readini(sessMan-options.ini,config,autoPart) == true ) {
79
        return Currently Enabled:echo -ag Auto Part Is Currently Enabled
80
      } else {
81
        return Currently Disabled:echo -ag Auto Part Is Currently Disabled
82
      }
83
    }
84
    if ( $1 == end ) {
85
      return -
86
    }
87
    return
88
  } elseif ( $2 == deleteSession ) {
89
    if ( $1 == $null ) {
90
      %pos = 1
91
    } else {
92
      %pos = $1
93
    }
94
    
95
    %sess = $ini(sessMan-sessions.ini,$network,%pos)
96
     if ( %sess == $null ) {
97
       return
98
     } else {
99
       return Delete %sess $+ :remini sessMan-sessions.ini $network %sess
100
     }
101
  } else {
102
    return
103
  }
104
}
105

    
106
alias sessMan.menuSess {
107
  if ( $1 == $null ) {
108
    %pos = 1
109
  } else {
110
    %pos = $1
111
  }
112
  
113
  %sess = $ini(sessMan-sessions.ini,$network,%pos)
114
   if ( %sess == $null ) {
115
     return
116
   } else {
117
     ;My load alias handles if it needs to auto part currently joined channels
118
     ;return %sess $+ :join $readini(sessMan-sessions.ini,$network,%sess)
119
     return %sess $+ :sessMan.load %sess
120
   }
121
}
(2-2/6)