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

	<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>2012-06-06T21:34:59-04:00</updated>

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

		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T21:32:04-04:00</updated>

		<published>2012-06-06T21:32:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99573#p99573</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99573#p99573"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99573#p99573"><![CDATA[
Thanks a lot <strong class="text-strong">nml375</strong>. It works great <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Wed Jun 06, 2012 9:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2012-06-06T13:17:22-04:00</updated>

		<published>2012-06-06T13:17:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99570#p99570</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99570#p99570"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99570#p99570"><![CDATA[
I'd suggest something along these lines;<br>Iterate through each badword-pattern, and get a list of matching words from the spoken text.<br>Since you'd like to use wildcards in your exempts-list, we'll have to iterate through this list for each match, and see if it should be exempted. If it should be exempted, move on to the next match; else, ban the user and be done with it.<br><br>Further, instead of manually adding the ban, kicking the user, and setting up a timer to finally remove it, why not just use the newchanban command with a custom expire-time?<br><br>The above converted to code:<div class="codebox"><p>Code: </p><pre><code>set advban(time) "30"set advban(chans) [list "#chan"]set advban(words) [list "*http*//*" "*http:*" "*www.*" "*.htm*" "*ftp*//*" "*www.*.co*" "*/server*.*.*"]set advban(exempts) [list]bind pubm - "*" advbanproc advban {nick host hand chan txt} {  global advban  set advban(chans) [string tolower $advban(chans)]  set chan [string tolower $chan]  set items [split [string tolower $txt]]  if {[validuser $hand] || [isop $nick $chan] || ([llength $advban(chans)] &gt; 0 &amp;&amp; [lsearch -exact $advban(chans) $chan] == -1)} {    return 0  }  foreach pattern $advban(words) {    foreach match [lsearch -all -inline $items [string tolower $pattern]] {      set exempt 0      foreach exception $advban(exempts) {        if {[string match -nocase $exception $match]} {          set exempt 1          break        }      }      if {$exempt} {        continue      } else {        newchanban $chan "*!*@[lindex [split $host "@"] 1]" "advban.tcl" "Spam match from ($match) is not allowed here" $advban(time)        return 1      }    }  }}</code></pre></div>Or, if we skip the wildcard matching of exempts:<div class="codebox"><p>Code: </p><pre><code>set advban(time) "30"set advban(chans) [list "#chan"]set advban(words) [list "*http*//*" "*http:*" "*www.*" "*.htm*" "*ftp*//*" "*www.*.co*" "*/server*.*.*"]set advban(exempts) [list "*example.com*"]bind pubm - "*" advbanproc advban {nick host hand chan txt} {  global advban  set advban(chans) [string tolower $advban(chans)]  set chan [string tolower $chan]  set items [split [string tolower $txt]]  if {[validuser $hand] || [isop $nick $chan] || ([llength $advban(chans)] &gt; 0 &amp;&amp; [lsearch -exact $advban(chans) $chan] == -1)} {    return 0  }  foreach pattern $advban(words) {    foreach match [lsearch -all -inline $items $pattern] {      if {[lsearch -exact $advban(exempts) $match]} {        continue      } else {        newchanban $chan "*!*@[lindex [split $host "@"] 1]" "advban.tcl" "Spam match from ($match) is not allowed here" $advban(time)        return 1      }    }  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jun 06, 2012 1:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-06-06T10:15:50-04:00</updated>

		<published>2012-06-06T10:15:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99569#p99569</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99569#p99569"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99569#p99569"><![CDATA[
Oh sorry, forgot a ! in:<div class="codebox"><p>Code: </p><pre><code>if {[string length $advban(chans)]} return </code></pre></div>that should be:<div class="codebox"><p>Code: </p><pre><code>if {![string length $advban(chans)]} return </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Jun 06, 2012 10:15 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T09:30:09-04:00</updated>

		<published>2012-06-06T09:30:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99567#p99567</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99567#p99567"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99567#p99567"><![CDATA[
Hi caesar,<br><br>I just tested it but it doesn't work at all. Nothings happen when the badwords trigger said on channel.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Wed Jun 06, 2012 9:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-06-06T10:15:10-04:00</updated>

		<published>2012-06-06T08:29:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99565#p99565</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99565#p99565"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99565#p99565"><![CDATA[
Something like this:<div class="codebox"><p>Code: </p><pre><code>set advban(time) "30"set advban(chans) "#chan"set advban(words) "*http*//* *http:* *www.* *.htm* *ftp*//* *www.*.co* */server*.*.*"set advban(exempts) ""bind pubm - "*" advbanproc advban {nick host hand chan txt} {global advbanif !{[string length $advban(chans)]} returnif {[lsearch -exact $advban(chans) $chan] == -1} returnif {[validuser $nick] &amp;&amp; [isop $nick $chan]} returnset found 0foreach word [split $txt] {   set word [string tolower $word]   if {[lsearch -equal $advban(exempts) $word] != -1} break   foreach element [split $advban(words)] {  if {![string match -nocase $word $element]} continue  set found 1  set badword $word  break   }}if {$found} {set ban *!*@[lindex [split $host @] 1]putquick "MODE $chan +b $ban"putquick "KICK $chan $nick :Spam match from ($badword) is not allowed here"timer $advban(time) [list "pusmode $chan -b $ban"]}}</code></pre></div>Haven't tested so let me know if you get any issues.<br><br>Edit: fixed typo.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Jun 06, 2012 8:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T08:09:43-04:00</updated>

		<published>2012-06-06T08:09:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99564#p99564</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99564#p99564"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99564#p99564"><![CDATA[
The same error caesar<blockquote class="uncited"><div>Tcl error [spamban]: bad option "-equal": must be -all, -ascii, -decreasing, -dictionary, -exact, -glob, -increasing, -inline, -integer, -not, -real, -regexp, -sorted, or -start</div></blockquote>Is it correct the placement of my code?<div class="codebox"><p>Code: </p><pre><code>proc advban {nick host hand chan txt} {   global advban   if {![validuser $nick] &amp;&amp; ![isop $nick $chan]} {   set advban(chans) [string tolower $advban(chans)]   set chan [string tolower $chan]   if {([string length [string trim $advban(chans)]] != 0) &amp;&amp; ([lsearch -exact [split $advban(chans)] $chan] == -1)} {return 0}   foreach exempt $advban(exempts) {      if {[lsearch $txt $exempt]} {return 0}   }  set found 0   foreach word [split $txt] {   if {[lsearch -equal $advban(exempts) [string tolower $word]] != -1} break    foreach element [split $advban(words)] {      if {![string match -nocase $word $element]} continue      set found 1      set badword $word      break   }}      if {$found} {       set ban *!*@[lindex [split $host @] 1]      putquick "MODE $chan +b $ban"      putquick "KICK $chan $nick :Spam match from ($word) is not allowed here"      timer $advban(time) {putquick "MODE $chan -b $ban"}   }}</code></pre></div>anyway, should i remove this code?<div class="codebox"><p>Code: </p><pre><code>foreach exempt $advban(exempts) {      if {[lsearch $txt $exempt]} {return 0}   } </code></pre></div>Since you already called it inside.<br><br>Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Wed Jun 06, 2012 8:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-06-06T04:34:16-04:00</updated>

		<published>2012-06-06T04:34:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99562#p99562</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99562#p99562"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99562#p99562"><![CDATA[
That's cos you have an outdated TCL library version. Anyway, replace:<div class="codebox"><p>Code: </p><pre><code>   if {[lsearch -nocase $advban(exempts) $word] != -1} break</code></pre></div>with:<div class="codebox"><p>Code: </p><pre><code>   if {[lsearch -equal $advban(exempts) [string tolower $word]] != -1} break</code></pre></div>Btw, you should move the:<div class="codebox"><p>Code: </p><pre><code>if {![validuser $nick] &amp;&amp; ![isop $nick $chan]} {</code></pre></div>after the <em class="text-italics">global advban</em> as it makes more sense to be there if you wish to skip a user if it's known to the bot AND is a channel operator.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Jun 06, 2012 4:34 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T00:42:09-04:00</updated>

		<published>2012-06-06T00:42:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99560#p99560</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99560#p99560"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99560#p99560"><![CDATA[
caesar, i got this error:<blockquote class="uncited"><div>Tcl error [advban]: bad option "-nocase": must be -all, -ascii, -decreasing, -dictionary, -exact, -glob, -increasing, -inline, -integer, -not, -real, -regexp, -sorted, or -start</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Wed Jun 06, 2012 12:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T00:29:39-04:00</updated>

		<published>2012-06-06T00:29:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99559#p99559</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99559#p99559"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99559#p99559"><![CDATA[
ok thanks caesar.. i'll give it a try now..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Wed Jun 06, 2012 12:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-06-06T00:21:30-04:00</updated>

		<published>2012-06-06T00:21:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99557#p99557</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99557#p99557"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99557#p99557"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>foreach element $list {if {whatever $element check you wish returns true} {do this action} else {do this second action as the if statement returned false}}</code></pre></div>In your case you should check each spoken word by the user and compare it with each element you have in the blackilst, but before that check if the word is not in the except list like this:<div class="codebox"><p>Code: </p><pre><code>set found 0foreach word [split $txt] {if {[lsearch -nocase $advban(exempts) $word] != -1} breakforeach element [split $advban(words)] {if {![string match -nocase $word $element]} continueset found 1set badword $wordbreak}}if {$found} {do whatever you wish as there has been a match with one of the words in the blacklist and that word has been stored in $badword variable}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Jun 06, 2012 12:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-05T23:42:05-04:00</updated>

		<published>2012-06-05T23:42:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99556#p99556</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99556#p99556"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99556#p99556"><![CDATA[
I tried but doesn't work..<br><br>Ok here's the full code:<div class="codebox"><p>Code: </p><pre><code>set advban(time) "30"set advban(chans) "#chan"set advban(words) "*http*//* *http:* *www.* *.htm* *ftp*//* *www.*.co* */server*.*.*"set advban(exempts) ""bind pubm - "*" advbanproc advban {nick host hand chan txt} {global advbanset advban(chans) [string tolower $advban(chans)]set chan [string tolower $chan]if {([string length [string trim $advban(chans)]] != 0) &amp;&amp; ([lsearch -exact [split $advban(chans)] $chan] == -1)} {return 0}foreach exempt $advban(exempts) {if {[lsearch $txt $exempt]} {return 0}}foreach word $advban(words) {    if {![string match -nocase $word $txt]} {continue}}if {![validuser $nick] &amp;&amp; ![isop $nick $chan]} {set ban *!*@[lindex [split $host @] 1]putquick "MODE $chan +b $ban"putquick "KICK $chan $nick :Spam match from ($word) is not allowed here"timer $advban(time) {putquick "MODE $chan -b $ban"}}}</code></pre></div>I got 2 errors there. the $word on kick msg doesnt work and the timer also doesnt work. It says wrong $chan for the timer part.<br><br>Please help. Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Tue Jun 05, 2012 11:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-06-05T13:50:48-04:00</updated>

		<published>2012-06-05T13:50:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99551#p99551</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99551#p99551"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99551#p99551"><![CDATA[
Also, in order to go to the next element in the list if a statement is false use <em class="text-italics">continue</em> not <em class="text-italics">return </em>. Example:<div class="codebox"><p>Code: </p><pre><code>foreach word $advert(words) {  if {![string match -nocase $word $txt]} continue</code></pre></div>that means if the current element that is taken from the $advert(words) doesn't match the $txt then it will continue with the next element. In order to stop the iteration use <em class="text-italics">break</em> instead of continue.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Jun 05, 2012 1:50 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2012-06-05T12:32:10-04:00</updated>

		<published>2012-06-05T12:32:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99549#p99549</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99549#p99549"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99549#p99549"><![CDATA[
When using foreach-loops to iterate though lists, you specify an iterator-variable (in your code it's <em class="text-italics">word</em>), which will be updated with the next element in the list upon each iteration of the list. Thus, you should not use lindex on the list to extract the item.<br><div class="codebox"><p>Code: </p><pre><code>foreach word $advert(words) {  if {[string match -nocase $word $txt]} {...</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Jun 05, 2012 12:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gasak]]></name></author>
		<updated>2012-06-06T21:34:59-04:00</updated>

		<published>2012-06-05T01:13:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99544#p99544</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99544#p99544"/>
		<title type="html"><![CDATA[[SOLVED]variable inside the proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99544#p99544"><![CDATA[
Hi,<br><br>I don't understand yet much about list operation in TCL. I just starting learning TCL tho' <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"> I have question about calling variable inside the proc.<br><br>For example i have this list<div class="codebox"><p>Code: </p><pre><code>set advert(words) "*http:* *www.* *.com*"</code></pre></div>And i want to call that list inside the proc to match the kick reason.<br><div class="codebox"><p>Code: </p><pre><code>foreach word $advert(words) {    if {[string match -nocase [lindex $advert(words)] $txt] } {return 0}}</code></pre></div>So i need it for my kick reason<div class="codebox"><p>Code: </p><pre><code>putserv "KICK $chan $nick :spam match from $word not allowed!</code></pre></div>But i got confused on the list operation command. It detects the whole advert(words) list. I still have no idea what list operation to use. Is it an lrange, lindex, or other. Please teach me. My code are so massy <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br><br>Thank you<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11310">gasak</a> — Tue Jun 05, 2012 1:13 am</p><hr />
]]></content>
	</entry>
	</feed>
