<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/20875" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2020-11-14T07:45:26-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/20875</id>

		<entry>
		<author><name><![CDATA[Gulio]]></name></author>
		<updated>2020-11-14T07:45:26-04:00</updated>

		<published>2020-11-14T07:45:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109168#p109168</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109168#p109168"/>
		<title type="html"><![CDATA[is not add and save the words/phrases in file badwords.txt]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109168#p109168"><![CDATA[
I have 1 problem is not add and save word/phrase in file badwords.txt<br>can someone give 1 look to see what is wrong to be fixed if someone have time and desire to help thx<br><div class="codebox"><p>Code: </p><pre><code>setudef flag badwordset badwordfile "badwords.txt"namespace eval bw {set file $::badwordfileset list {}# this procedure reloads the data from the fileproc load_data {} {variable filevariable dataif {![file exists $file]} {set fp [open $file a]close $fp}set fp [open $file r]set lines [split [read $fp] "\n"]close $fpset data {}foreach line $lines {set line [string trim $line]if {$line eq {}} { continue }lappend data $line}}# this procedure writes back the data to the fileproc save_data {} {variable filevariable dataif {![file exists $file]} {set fp [open $file a]close $fp}set fp [open $file w]set lines {}foreach line $data {set line [string trim $line]if {$line eq {}} { continue }lappend lines $line}set data $linesforeach line $data {puts $fp $line}close $fp}bind pub n|n .bw  bw::controlbind msg n|n .badd bw::add_badwordbind msg n|n .bdel bw::del_badwordbind pubm - * bw::pubm:badwordproc control {nick host handle chan args} {if { ![channel get $chan badword] &amp;&amp; [string compare $args "on"] == 0 } {channel set $chan +badwordputserv "NOTICE $nick :\002\0036BadWord\00318: \00347Is \0033ON \00347For \0034$chan\002"} elseif { [channel get $chan badword] &amp;&amp; [string compare $args "off"] == 0 } {channel set $chan -badwordputserv "NOTICE $nick :\002\0036badWord\00318: \00347Is \0034OFF \00347For \0033$chan\002"}}proc pubm:badword {nick uhost hand chan text} {global badwords variable dataset ban_time 5bw::load_dataif {[matchattr $hand "fo"]} { return 0 }if {[set chost [getchanhost $nick $chan]] ne ""} {switch -glob -- $chost {{*.irccloud.com} - {*.mibbit.com} - {*.kiwiirc.com} {set mask4x *![lindex [split $chost @] 0]@*}{default} {set mask4x [maskhost "$nick!$chost" 2]}}}if {[botisop $chan] &amp;&amp; ![isbotnick $nick]} {foreach badword $badwords {if {[string match -nocase "*[lindex [split $badword ,] 1]*" $text]} {regsub -all -- {-} $text {} textregsub -all -- {[-\^~\|_\*]} $text {} textputquick "MODE $chan -v+b $nick $mask4x "#putquick "KICK $chan $nick :Dont Swearing!"after {[expr $ban_time*1000*60] [list putquick "MODE $chan -b $mask4x"]}break}}}return 0}proc add_badword {nick ushost handle text} {variable filevariable data# load the data from the filebw::load_dataset badword [lindex [split $text] 0]if {$badword eq {}} {putserv "Notice $nick :\002\0034Oops?!\002 \0036Use:  \002\0033.badd &lt;word/phrase&gt;\002"return 0} else {set badword {}putserv "privmsg $nick : NOW badword is: $badword"foreach line $data {if {![string match -nocase $line $badword]} {lappend badwords $line}}if {$badword ne {}} {putserv "Notice $nick :\002\0034Sorry\002 \0036This Mask \002\00310$text\002 \0036exist already in \002\0033BadWords File\002."return 0}# add the host to the datalappend data $badword# write back to the filebw::save_dataputserv "NOTICE $nick :\002\0033DONE\002. \0034ADDED \0036The word/phrase \002\00310$text\002 \0036Successfully In \002\0033BadWords File\002"return 0}}proc del_badword {nick ushost handle text} {variable filevariable data# load the data from the filebw::load_dataset badword [lindex [split $text] 0]if {$badword eq {}} {putserv "NOTICE $nick :\002\0034Oops?!\002 \0036Use:  \002\0033.bdel &lt;word/phrase&gt;\002"return 0} else {set lines {}set badword {}foreach line $data {if {[string match -nocase $line $badword]} {lappend badwords $line} else {lappend lines $line}}if {$badword eq {}} {putserv "NOTICE $nick :\002\0034Sorry\002 \0036This word/phrase \002\00310$text\002 \0036does not exist in \002\0033BadWords File\002."return 0}set data $lines# write back to filebw::save_dataputserv "NOTICE $nick :\002\0033DONE\002. \0034REMOVED \0036The word/phrase \002\00310$text\002 \0036Successfully from \002\0033BadWords File\002."return 0}}proc main {} {variable filevariable dataif {![file exists $file]} {close [open $file a]} elseif {![info exists data]} {bw::load_data}putlog " \002\0036Badword ChanneL\002 \0036- \002\0033Loaded\002 "}}bw::main</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12887">Gulio</a> — Sat Nov 14, 2020 7:45 am</p><hr />
]]></content>
	</entry>
	</feed>
