File: netsplit.env

package info (click to toggle)
epic 3.004-17.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,192 kB
  • ctags: 3,197
  • sloc: ansic: 40,843; makefile: 530; sh: 129; perl: 17
file content (159 lines) | stat: -rw-r--r-- 4,042 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# NETSPLIT 7 - This script does it's best to suppress the excessive 
# joins and signoffs due ONLY to netsplits.  It should pass regular
# signoffs.   Need at least ircII2.2pre6
# Version II  handles multiple channels. 
# Version III ignores bogus signoff messages
# Version IV  handles multiple splits.
# Version V   handles multiple splits and ignores bogus signoff messages. also
#             adds timestamps to split/join messages
# Version VI  For ircII2.2pre8 and beyond. Uses encode() and decode() 
# Version VII Fixed a problem with encode() and decode() and case
#             sensitive channel names, + adding lformat()
#
# This one by Daemon
# CONVERTED for ircII2.2pre8
# Version V by poxaV (cgw@unt.edu), from Daemon's code
# modified last 7-03-93

#shows the current time in HH:MM:SS format
alias currtime @ function_return = word(3 $stime($time()))

# This function tests for bogus splits.
alias isbogus {
	if ([$3]) { @ function_return = 1 }
	if (rmatch(.$1. $isbogus.pats *..*)) { @ function_return = 1 }
	if (rmatch(.$2. $isbogus.pats *..*)) { @ function_return = 1 }
}

# Add patterns.. like /boguspat *bonk* *thud* *haha*
# that will NOT be treated as server names..
alias boguspat ^assign isbogus.pats $isbogus.pats $0-;echo $0- added

# Next two are pretty obvious
alias boguslist echo Pats: $isbogus.pats
alias bogusclear ^assign -isbogus.pats;echo Bogus list clean

# If first word in Signoff contains a period then assume servername
# and thus a a split.  Stash in assoc array.
ON ^CHANNEL_SIGNOFF "% % %.% %.%" {
	if (isbogus($1-)) 
		{ echo *** Quit: $1 \($0, $2-\) }
		{ ^netbroke $encode($tolower($0)) $encode($1) $encode($2).$encode($3) $2 $3 }
}

# Stuff array. Tell us what server broke and set split flag.
^alias netbroke {
	@ signcross[$2][$0][$1] = 1
	@ signoffs[$0][$1] = [$2]
	@ splittime[$2] = time()
	if ( !isbroke[$2] )
	{
		xecho -level OPNOTES *** Netsplit at $currtime() \($3-\)
		@ isbroke[$2] = 1
		@ splitname[$2] = [$3-]
	}
}

# When a person joins a channel.. Check them against the array.
# If they are in array, then remove silently.  Otherwards echo normally
ON #^JOIN -10 * {
	^netjoined $encode($tolower($1)) $encode($0) $1 $0 $USERHOST()
}

# Unset the split flag
alias netjoined {
	if ( signoffs[$0][$1] )
	{
		if ( isbroke[$signoffs[$0][$1]] )
		{
			xecho -level OPNOTES *** Netjoined at $currtime() \($splitname[$signoffs[$0][$1]]\)
		}
		^assign -isbroke[$signoffs[$0][$1]]
		^assign -signcross[$signoffs[$0][$1]][$0][$1]
		^assign -signoffs[$0][$1]
		@ rejoin = 1
	}
}

# Clear the array every 10 minutes to prevent excess garbage
on #^timer 70 * netclean

alias netclean {
	foreach splittime ii
	{
		foreach splittime.$ii jj
		{
			if ( time() - splittime[$ii][$jj] > 300 )
			{
				foreach signcross.$(ii).$jj xx
				{
					foreach signcross.$(ii).$(jj).$xx yy
					{
						^assign -signcross[$ii][$jj][$xx][$yy]
						^assign -signoffs[$xx][$yy]
					}
				}
				^assign -xx
				^assign -yy
				^assign -isbroke[$ii][$jj]
				^assign -splitname[$ii][$jj]
				^assign -splittime[$ii][$jj]
			}
		}
	}
	^assign -ii
	^assign -jj
}

alias netpurge {
	purge isbroke
	purge splitname
	purge splittime
	purge signcross
	purge signoffs
}

# If you want to supress mode changes by servers.. (ussually after a split)
# then uncomment next line
# ^on ^mode "%.%" #

# If you want to look an array.. Type /show <arrayname>
# Lists keys and contents
alias showsplit {
	if ([$($0)]) {echo $0 $($0)}
	foreach $0 ii
	{
		showsplit $0.$ii
	}
}

alias purge {
	foreach $0 ii
	{
		purge $0.$ii
	}
	^assign -ii
	^assign -$0
}

alias wholeft {
	foreach signoffs ii
	{
		foreach signoffs.$ii jj
		{
			echo $lformat(15 $decode($ii)) $lformat(10 $decode($jj)) $splitname[$signoffs[$ii][$jj]]
		}
	}
	^assign -ii
	^assign -jj
}

# format and lformat differ from $[-num]var and $[num]var in that
# They don't chop off the string if it is too long.

alias lformat {
	@ IRCII.word = [$1-]
	if (@IRCII.word < [$0]) 
		{ @ function_return = [$([$0]IRCII.word)] } 
		{ @ function_return = [$IRCII.word] } 
}