<?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/18102" />

	<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>2010-10-31T12:31:52-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-10-31T12:31:52-04:00</updated>

		<published>2010-10-31T12:31:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94938#p94938</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94938#p94938"/>
		<title type="html"><![CDATA[bad word and Guest kicker]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94938#p94938"><![CDATA[
Not to be rude, but the "less-than-optimal" resource usage is the least of concern with this script.<br>In essence, there are two flaws, of which one can be considered severe:<ul><li>You treat strings from untrusted sources as list. This is a bad practise, and will break the script on certain inputs.<br>Generally not exploitable.</li><li>You perform no validation or sanitation of remote data inserted into your SQL-queries.<br>Thus, your script is vulnerable to Remote SQL-injection attacks. The script does not connect with multistatement support enabled, which does limit the impact of this poor coding. That, however, is not an excuse for not validating/sanitizing the data in the first place.</li></ul>A few advices:<br>Read up on the mysql_real_escape() command (available through ::mysql::escape in mysqltcl) for protecting your queries against SQL-injections.<br>Consider keeping a single sql connection, and use this single one for each and all transactions, rather than dropping and reconnecting for every single query.<br>Read up on the differences between strings and lists in tcl. You'll probably find these commands useful as well: <strong class="text-strong">list</strong>, <strong class="text-strong">split</strong>, and <strong class="text-strong">join</strong>. Also remember that <strong class="text-strong">lindex</strong> does return a string (from a list), while <strong class="text-strong">lrange</strong> returns a list (a subset from a list).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Oct 31, 2010 12:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[madpinger]]></name></author>
		<updated>2010-10-31T10:47:59-04:00</updated>

		<published>2010-10-31T10:47:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94936#p94936</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94936#p94936"/>
		<title type="html"><![CDATA[bad word and Guest kicker]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94936#p94936"><![CDATA[
<blockquote class="uncited"><div>You do realize that this script is not resources friendly due to it connecting to the database and check for each word every time a user says something in the channel? A better alternative would be either go for a flat file or sqlite3.</div></blockquote>sqlite3 is &lt;3,  It's really nice.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11373">madpinger</a> — Sun Oct 31, 2010 10:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2010-10-31T05:10:46-04:00</updated>

		<published>2010-10-31T05:10:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94932#p94932</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94932#p94932"/>
		<title type="html"><![CDATA[bad word and Guest kicker]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94932#p94932"><![CDATA[
You do realize that this script is not resources friendly due to it connecting to the database and check for each word every time a user says something in the channel? A better alternative would be either go for a flat file or sqlite3.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sun Oct 31, 2010 5:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[doggo]]></name></author>
		<updated>2010-10-30T20:09:32-04:00</updated>

		<published>2010-10-30T20:09:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94931#p94931</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94931#p94931"/>
		<title type="html"><![CDATA[bad word and Guest kicker]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94931#p94931"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>CREATE TABLE  `CHANGE_THIS`.`bad_words` (`bword` VARCHAR( 25 ) NOT NULL , `bkick` VARCHAR( 250 ) NOT NULL ,KEY  `bword` (  `bword` ) ,KEY  `bkick` (  `bkick` )) ENGINE = MYISAM DEFAULT CHARSET = latin1;</code></pre></div><div class="codebox"><p>Code: </p><pre><code>CREATE TABLE  `CHANGE_THIS`.`channel_users` (`nick_id` INT( 25 ) NOT NULL AUTO_INCREMENT , `nick` VARCHAR( 35 ) NOT NULL , `title` VARCHAR( 200 ) NOT NULL DEFAULT  'Peasant', `host` VARCHAR( 200 ) NOT NULL , `requests` INT( 100 ) NOT NULL DEFAULT  '0', `fills` INT( 100 ) NOT NULL DEFAULT  '0', `points` INT( 100 ) NOT NULL DEFAULT  '0', `leeched` INT( 25 ) NOT NULL DEFAULT  '0',KEY  `nick_id` (  `nick_id` ) ,KEY  `leeched` (  `leeched` ) ,</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11046">doggo</a> — Sat Oct 30, 2010 8:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[doggo]]></name></author>
		<updated>2010-10-30T19:50:29-04:00</updated>

		<published>2010-10-30T19:50:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94930#p94930</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94930#p94930"/>
		<title type="html"><![CDATA[bad word and Guest kicker]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94930#p94930"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>package require mysqltcl 3.05namespace eval bad {namespace eval words {variable add_chan "#nzbmatrix.chat"#DB CONNECTIONvariable db_host "************"variable db_port "************"variable db_user "************"variable db_pass "************"variable db_name "************"#BAD WORDS TABLEvariable db_table "bad_words"variable db_badword "bword"variable db_kickmsg "bkick"#CHANNEL USER TABLEvariable db_user_table "channel_users"variable db_user_nick "nick"variable db_user_title "title"variable db_user_host "host"variable db_user_requests "requests"variable db_user_fills "fills"variable db_user_points "points"variable db_user_leeched "leeched"#TRIGGERSvariable  rehashtrig "-rehash"variable addtrig "-add"variable deltrig "-del"#BINDSbind join -|- "$bad::words::add_chan %" bad::user_add::add_userbind pub m|m $bad::words::rehashtrig bad::re_hash::rehash_funcbind msg -|- $bad::words::addtrig bad::badwordadd::addbadwordbind pubm -|- "$bad::words::add_chan *" bad::checkword::wordcheckerbind join -|- "$bad::words::add_chan *Guest*" bad::checknick::nickcheckbind msg -|- $bad::words::deltrig bad::badworddel::delbadword#END SETTINGS NAMESPACE}namespace eval re_hash {proc rehash_func {nick uhost hand chan arg} {rehashputquick "PRIVMSG $bad::words::add_chan :done.."}#END RE_HASH NAMESPACE}namespace eval user_add {proc add_user {nick host hand chan} {set nick_ident *!*@[lindex [split [getchanhost $nick] "@"] 1]    set check_user_handle [::mysql::connect -host $bad::words::db_host -port $bad::words::db_port -user $bad::words::db_user -password $bad::words::db_pass -db $bad::words::db_name];set added_user_get [::mysql::sel $check_user_handle "SELECT $::bad::words::db_user_nick FROM $::bad::words::db_user_table WHERE $::bad::words::db_user_nick = '$nick'" -flatlist];if { $added_user_get != "" } {::mysql::endquery $check_user_handle::mysql::close $check_user_handle} elseif {$added_user_get == ""} {set add_user_handle [::mysql::connect -host $bad::words::db_host -port $bad::words::db_port -user $bad::words::db_user -password $bad::words::db_pass -db $bad::words::db_name];if {[catch {set adduser [::mysql::exec $add_user_handle "INSERT INTO $bad::words::db_user_table ($bad::words::db_user_nick, $bad::words::db_user_host) VALUES ('$nick', '$nick_ident'   )"]; } badentry]} {::mysql::endquery $add_user_handle::mysql::close $add_user_handle} else {::mysql::endquery $add_user_handle::mysql::close $add_user_handle} }}#END USER_ADD NAMESPACE}namespace eval badwordadd {proc addbadword {nick uhost hand text} {set add_word [lindex $text 0]set add_kick_msg [lrange $text 1 end]if {$add_kick_msg == ""} {putquick "NOTICE $nick :you forgot a kick msg..";return}if { [isop $nick $bad::words::add_chan] == 0 } {putquick "PRIVMSG $bad::words::add_chan :$nick tried to add '$add_word : $add_kick_msg'  @ status is needed to add words";return}set badword_handle [::mysql::connect -host $bad::words::db_host -port $bad::words::db_port -user $bad::words::db_user -password $bad::words::db_pass -db $bad::words::db_name];if {[catch {set addmp3 [::mysql::exec $badword_handle "INSERT INTO $bad::words::db_table ($bad::words::db_badword, $bad::words::db_kickmsg ) VALUES ('$add_word', '$add_kick_msg'   )"]; } badentry]} {putquick "NOTICE $nick :$badentry"::mysql::endquery $badword_handle::mysql::close $badword_handle} else { putquick "NOTICE $nick :\00307Added \017 | $add_word | $add_kick_msg"::mysql::endquery $badword_handle::mysql::close $badword_handle}}#END BADWORDADD NAMESPACE}namespace eval checkword {proc wordchecker {nick uhost hand chan text} {set nick_ident *!*@[lindex [split [getchanhost $nick] "@"] 1]regsub -all {\003([0-9]{1,2}(,[0-9]{1,2})?)?} $text "" textregsub -all {\017|\037|\002|\026|\006|\007} $text "" textset line [split $text]set fnd 0foreach wordsaid $line {set check_word_handle [::mysql::connect -host $bad::words::db_host -port $bad::words::db_port -user $bad::words::db_user -password $bad::words::db_pass -db $bad::words::db_name];set check_word [::mysql::sel $check_word_handle "SELECT $::bad::words::db_badword, $::bad::words::db_kickmsg FROM $::bad::words::db_table WHERE $::bad::words::db_badword = '$wordsaid'" -flatlist];::mysql::endquery $check_word_handle::mysql::close $check_word_handleif { $check_word == ""} {  } else {incr fnd 1}}if { $fnd != "0" &amp;&amp; [isop $nick $chan] == 0 } {set why [lrange $check_word 1 end]regsub -all {\{} $why "" whyregsub -all {\}} $why "" whyputquick "KICK $chan $nick :$why"} else { return}}#END CHECKWORDADD NAMESPACE}namespace eval checknick {proc nickcheck {nick uhost hand chan} {set kick_reason "NO! Guests allowed.. Change your nick by typing /nick nzblover and rejoin" putquick "MODE $chan +b $nick"putquick "KICK $chan $nick :$kick_reason"utimer 15 [list putquick "MODE $chan -b $nick"]} #END CHECKNICK NAMESPACE}namespace eval badworddel {proc delbadword {nick uhost hand text} {set add_word [lindex $text 0]if {$add_word == ""} {putquick "NOTICE $nick :what did you want me to remove exactly?";return}if { [isop $nick $bad::words::add_chan] == 0 } {putquick "PRIVMSG $bad::words::add_chan :$nick tried to remove '$add_word' @ status is needed to remove words";return}set badword_handle [::mysql::connect -host $bad::words::db_host -port $bad::words::db_port -user $bad::words::db_user -password $bad::words::db_pass -db $bad::words::db_name];set word_take [::mysql::exec $badword_handle "DELETE FROM $bad::words::db_table WHERE $bad::words::db_badword = '$add_word'"];if { $word_take == 0 } {putquick "NOTICE $nick :nothing found for '$addword'"::mysql::endquery $badword_handle::mysql::close $badword_handle} else { putquick "NOTICE $nick :\00307Removed \017 | $add_word "::mysql::endquery $badword_handle::mysql::close $badword_handle}}#END BADWORDDEL NAMESPACE}#END ALL NAMESPACES}</code></pre></div>wrote this script works well as is.. i  just wondered if there was anything i could maybe make better as i have only just got into coding <br><br>stores users on join and bad words into a mysql table also checks for bad words said on a channel, if one is said the bot kicks the user with the msg you added<br><br>ou need to be an @ in the channel you set, triggers are  <br>-rehash requires you to be a bot master.<br><div class="codebox"><p>Code: </p><pre><code>-rehash *to rehash the bot*/msg botnick -add badword some custom kick msg *to add a bad word*/msg botnick -del badword *to remove a bad word*</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11046">doggo</a> — Sat Oct 30, 2010 7:50 pm</p><hr />
]]></content>
	</entry>
	</feed>
