/[cvs]/eggdrop1.6/scripts/klined.tcl
ViewVC logotype

Contents of /eggdrop1.6/scripts/klined.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Dec 21 17:35:08 1999 UTC (19 years, 10 months ago) by fabian
Branch: MAIN
CVS Tags: eggdrop105020, r1, eggdrop10503, eggdrop_1_6_15, eggdrop_1_6_13, eggdrop10403, blah, eggdrop1_6_9, eggdrop1_6_5, eggdrop105040, test, v2_0, eggdrop1_6_7, eggdrop1_6_6, eggdrop1_6_11, HEAD
Changes since 1.1: +2 -0 lines
File MIME type: application/x-tcl
Tothwolf's id-header

1 #
2 # KLined.TCL - Version 1.0
3 # By Ian Kaney - ikaney@uk.defiant.org
4 #
5 # $Id$
6 #
7 # Even at the best of times, your bot will get k-lined by one operator or
8 # another on a server you're running your bot on. This script will 'hopefully'
9 # handle this by removing it from your bot's server list when it detects
10 # you've been k-lined there. Thus, stopping IRC server admins getting
11 # rather peeved at the constant connects from your host.
12 #
13 # USAGE:
14 # The actual handling of removing the server from your server list
15 # and writing it to the 'klines' file is handled automatically when
16 # your bot receives the k-line signal, but there are some DCC commands
17 # that have been added, these are:
18 #
19 # .klines - Lists the 'klines' file showing servers that your bot
20 # has registered as being k-lined on.
21 # .unkline <server> - Removes the k-line from the server *joke* ;)
22 # Actually, this removes the server from the list
23 # of servers to remove.
24 #
25
26 # Bindings
27 # ---
28 bind load - server remove_kservers
29 bind raw - 465 woah_klined
30 bind dcc n klines list_kservers
31 bind dcc n unkline unkline_server
32
33 # Variables
34 # ---
35 # Change this to suite your tastes - if you can't be bothered, or
36 # don't know how, leave it.
37 set kfile "klines"
38
39 proc list_kservers {handle idx args} {
40 global kfile
41
42 putcmdlog "#$handle# klines"
43 set fd [open $kfile r]
44 set kservers { }
45
46 while {![eof $fd]} {
47 set tmp [gets $fd]
48 if {[eof $fd]} {break}
49 set kservers [lappend kservers [string trim $tmp]]
50 }
51 close $fd
52 if {[llength $kservers] == 0} {
53 putdcc $idx "No k-lined servers."
54 return 0
55 }
56 putdcc $idx "My k-lined server list:\n"
57 foreach tmp $kservers {
58 putdcc $idx $tmp
59 }
60 }
61
62 proc unkline_server {handle idx args} {
63 global kfile
64
65 set kservers {}
66
67 set fd [open $kfile r]
68 set rem [lindex $args 0]
69
70 putcmdlog "#$handle# unkline $rem"
71
72 while {![eof $fd]} {
73 set tmp [gets $fd]
74 if {[eof $fd]} {break}
75 set kservers [lappend kservers [string trim $tmp]]
76 }
77 close $fd
78
79 set fd [open $kfile w]
80 set flag "0"
81
82 foreach tmp $kservers {
83 if {$tmp == $rem} {
84 set flag "1"
85 }
86 if {$tmp != $rem} {
87 puts $fd $tmp
88 }
89 }
90 close $fd
91 if {$flag == "0"} {
92 putdcc $idx "Could not find $rem in the k-lined server list."
93 }
94 if {$flag == "1"} {
95 putdcc $idx "Removed server $rem from k-lined server list."
96 }
97 }
98
99 proc remove_kservers {module} {
100 global kfile
101 global server servers
102
103 if {[catch {set fd [open $kfile r]}] != 0} {
104 set fd [open $kfile w]
105 close $fd
106 set fd [open $kfile r]
107 }
108
109 while {![eof $fd]} {
110 set from [string trim [gets $fd]]
111 set name "*$from*"
112 if {[eof $fd]} {break}
113
114 for {set j 0} {$j >= 0} {incr j} {
115 set x [lsearch $servers $name]
116 if {$x >= 0} {
117 set servers [lreplace $servers $x $x]
118 }
119 if {$x < 0} {
120 if {$j >= 0} {
121 putlog "Removed server: $from"
122 }
123 break
124 }
125 }
126 }
127 close $fd
128 return 1
129 }
130
131 proc woah_klined {from keyword arg} {
132
133 global kfile
134 global server servers
135
136 set kservers {}
137
138 set fd [open $kfile r]
139
140 while {![eof $fd]} {
141 set tmp [gets $fd]
142 if {[eof $fd]} {break}
143 set kservers [lappend kservers [string trim $tmp]]
144 }
145 close $fd
146
147 set flag "0"
148
149 foreach tmp $kservers {
150 if {$tmp == $from} {
151 set flag "1"
152 }
153 }
154
155 if {$flag != "1"} {
156 set fd [open $kfile a]
157 puts $fd $from
158 close $fd
159 }
160
161 set name "*$from*"
162
163 for {set j 0} {$j >= 0} {incr j} {
164 set x [lsearch $servers $name]
165 if {$x >= 0} {
166 set servers [lreplace $servers $x $x]
167 }
168 if {$x <= 0} {
169 if {$j >= 0} {
170 putlog "Removed server: $from"
171 }
172 break
173 }
174 }
175 return 1
176 }
177
178 putlog "TCL loaded: k-lined"
179 remove_kservers server

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23