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

	<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>2006-11-12T22:22:11-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-11-12T22:22:11-04:00</updated>

		<published>2006-11-12T22:22:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68004#p68004</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68004#p68004"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68004#p68004"><![CDATA[
"array names" is your friend here; returns a list of all the keys in a speciffic array.<br>Something like this I suppose:<div class="codebox"><p>Code: </p><pre><code>proc test_nicks {} { global warned foreach nick [array names warned] {  if {$warned($nick) == 1} {   #evil spammer  } }}</code></pre></div>Modify to suit your needs<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Nov 12, 2006 10:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nara]]></name></author>
		<updated>2006-11-12T20:32:12-04:00</updated>

		<published>2006-11-12T20:32:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67993#p67993</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67993#p67993"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67993#p67993"><![CDATA[
<blockquote class="uncited"><div>Store them in an array (as I showed you above).</div></blockquote>Then where does the list of nicks to check come from? [I never got much experience in lists and while loops, so if you could help, I'd most appreciate.]<br><br>~Nara<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8006">Nara</a> — Sun Nov 12, 2006 8:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2006-11-12T20:18:36-04:00</updated>

		<published>2006-11-12T20:18:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67990#p67990</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67990#p67990"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67990#p67990"><![CDATA[
Store them in an array (as I showed you above).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sun Nov 12, 2006 8:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nara]]></name></author>
		<updated>2006-11-12T20:16:52-04:00</updated>

		<published>2006-11-12T20:16:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67989#p67989</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67989#p67989"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67989#p67989"><![CDATA[
Alright - here's what I'm trying to do, so help me out here.<br><br>This is an anti-ad script. I already fixed the wildcard and the bind [mistakes from coding all of this in under 2 minutes].<br><br>It needs to have a warning system, hence the $nick.warned stuff. I need a good way to store all nicks that are warned and then permit me to run them all through hourly. [probably with a bind time for hourly if it can be put into a protocol?]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8006">Nara</a> — Sun Nov 12, 2006 8:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2006-11-12T12:30:45-04:00</updated>

		<published>2006-11-12T12:30:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67949#p67949</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67949#p67949"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67949#p67949"><![CDATA[
I noticed it, but didn't edit it. After all, it's just an example <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sun Nov 12, 2006 12:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[metroid]]></name></author>
		<updated>2006-11-12T12:25:55-04:00</updated>

		<published>2006-11-12T12:25:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67947#p67947</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67947#p67947"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67947#p67947"><![CDATA[
I think you mean<br><div class="codebox"><p>Code: </p><pre><code>set warned($nick) 1</code></pre></div> in the first proc <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5078">metroid</a> — Sun Nov 12, 2006 12:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2006-11-12T12:09:53-04:00</updated>

		<published>2006-11-12T12:09:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67944#p67944</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67944#p67944"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67944#p67944"><![CDATA[
You need to create not a variable, but an array. A global array. For example:<div class="codebox"><p>Code: </p><pre><code>proc bla {nick uhost hand chan} { global warned # ...etc set warned($nick) 0 timer 60 [list blo $nick]}proc blo nick { global warned if {$warned($nick) == 1} { set warned($nick) 0 }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sun Nov 12, 2006 12:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-11-12T01:11:32-04:00</updated>

		<published>2006-11-12T01:11:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67918#p67918</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67918#p67918"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67918#p67918"><![CDATA[
Ohh my..is that the entire script? Cos..it's wrong in a lot of places..Starting with:<br><br>bind pub - * battle:mainchan <br><br>if you want a trigger to work on any possible input, you need to use pubm, which accepts wildcards, bind pub does not.<br><br>Where are the text1 and text2 global vars defined?  They're not in the script as posted..<br><br>"string match"  needs wildcards like <br><br>string match -nocase "*.com*" $text<br><br>unless you anticipate an exact match (just .com in the $text var)<br><br>text input from users should be split, [split $text] to make it safe, many functions will choke on tcl-special chars, otherwise. Read: <a href="http://www.peterre.com/characters.html" class="postlink">http://www.peterre.com/characters.html</a><br><br>And actually, instead of using string match so much, and since you'd be wise to [split $text]  you'd prolly be better off using lsearch to compare lists, like for your channel check:<br><br>in the global space:<br>set mychans "#mychan #chan2 #etc"<br><br>then within the pub (or pubm)q proc:<div class="codebox"><p>Code: </p><pre><code>proc whatever {nick uhost hand chan text} {global mychansif {[lsearch -exact $mychans $chan]} {          #this is a matching channel          # do stuff} else {           # this is not a match           # return}</code></pre></div>Using [split] creates a list, on which you can use lsearch, lindex, lrange, lreplace, etc.<br><br>As for the timer, I'd make a seperate proc to run the test in. You'd need to set a global var to pass to the other proc as well, so within your <br>proc battle:mainchan, make nickwarned a global var, add it to the list of global vars at the beginning of the proc, then have it set by the proc. Also within the proc battle:mainchan you set your timer:<br><br>timer 60 [list someproc $nick]<br><br>Then when your timer runs the seperate proc for testing, you add that nickwarned var as a global there too:<div class="codebox"><p>Code: </p><pre><code>proc someproc {nick}    global nickwarned     if {$nick.warned == 1} {set $nick.warned 0}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sun Nov 12, 2006 1:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-11-11T18:59:20-04:00</updated>

		<published>2006-11-11T18:59:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67914#p67914</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67914#p67914"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67914#p67914"><![CDATA[
It will need some modifications..<br>First of all, (u)timer take two arguments, of which one is the delay..<div class="codebox"><p>Code: </p><pre><code>timer 60 if {$nick.warned == 1} {set $nick.warned 0}</code></pre></div>has 4 arguments == 2 too many...<br>Would have to be changed into something like this:<div class="codebox"><p>Code: </p><pre><code>timer 60 [list if {$nick.warned == 1} {set $nick.warned 0}]</code></pre></div>However, this will only work as expected if $nick.warned is a variable in globalspace, as this code snippet is not run within the environment of of the proc... Also, since the code includes a variable controlled by users, there's the risk of code injection (changing nick to foo[die]bar might get ugly if proper encapsulations are not in place)..<br><br>There's a few more things to considder, that I'll get to alittle later this evening<br><br><em class="text-italics">edit:</em><br>The main problem with your code above is the $nick.warned variable. You mix using it as a proc-local variable and a globalspace variable, without using "global" or any other means of accessing globalspace variables from proc's..<br>Since you wish to use dynamic variable names, this gets alittle messier..<br>Also due to the same reason, you really should test wether the variable actually exists before you try to use it (even in if-conditionals)<br><br>Finally, using a dot "." in your variable name will cause problems with conditional statements, considder using a different separator-char or named arrays (also solves the problem with dynamic variable names)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Nov 11, 2006 6:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nara]]></name></author>
		<updated>2006-11-11T18:26:36-04:00</updated>

		<published>2006-11-11T18:26:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67911#p67911</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67911#p67911"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67911#p67911"><![CDATA[
Alright, here's what I'm doing:<br><br>I'm doing a warning script within my ads/kicks, and this is the script I plan on using. Will this work or will it need mods?<br><div class="codebox"><p>Code: </p><pre><code>bind pub - * battle:mainchanproc battle:warnnick {nick host hand chan text} {putserv "NOTICE $nick :You almost stepped on a landmine there Mr. Rock star. check out @rockrules and @advertising"}proc battle:mainchan {nick host hand chan text} {        global text1 text2 mainchanset chan [string tolower $chan]if {[string equal $chan $mainchan]} {set text [stripcodes bcruag $text]if {[string match -nocase "text1" $text] || [string match -nocase "text2" $text} {return 0} elseif {[string match -nocase "#" $text] || [string match -nocase "www" $text] || [string match -nocase ".com" $text] || [string match -nocase ".net" $text] || [string match -nocase ".org" $text] || [string match -nocase "http" $text]} {battle:warnnick nick host hand chan textif {$nick.warned == 1} {putserv "PRIVMSG Chanserv :$mainchan addtimedban $nick 3m Ads"set $nick.warned 0} else {set $nick.warned 1timer 60 if {$nick.warned == 1} {set $nick.warned 0}}} else {return 0}}}</code></pre></div>~Nara<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8006">Nara</a> — Sat Nov 11, 2006 6:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-11-11T15:30:22-04:00</updated>

		<published>2006-11-11T15:30:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67899#p67899</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67899#p67899"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67899#p67899"><![CDATA[
Yes, it can be run from an if test within the global space, as nml said, of a script (eg, outside of a proc)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sat Nov 11, 2006 3:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-11-11T13:37:14-04:00</updated>

		<published>2006-11-11T13:37:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67896#p67896</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67896#p67896"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67896#p67896"><![CDATA[
(u)timer takes two arguments, the time to delay, and &lt;tcl-command&gt;<br>That is, anything in &lt;tcl-command&gt; will be executed by the tcl-interpreter once the delay has passed. You'll have to remember that this will be run in globalspace, and not the namespace occupied by the proc that called it (if any).<br>Also, keep in mind the ways the tcl-interpreter operates, especially the variable- and command substitutions.<br>The two snippets below look quite similar, yet behave quite differently (both assumed to be run in globalspace)<br><div class="codebox"><p>Code: </p><pre><code>timer 10 [list puthelp "PRIVMSG #mychannel :I'm $botnick"]timer 10 [list puthelp {PRIVMSG #mychannel :I'm $botnick}]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Nov 11, 2006 1:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nara]]></name></author>
		<updated>2006-11-11T09:24:34-04:00</updated>

		<published>2006-11-11T09:24:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67889#p67889</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67889#p67889"/>
		<title type="html"><![CDATA[Does utimer/timer have to be a proc or can it be like an if?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67889#p67889"><![CDATA[
Alright - just a quick q, no script. See topic.<br><br>~Nara<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8006">Nara</a> — Sat Nov 11, 2006 9:24 am</p><hr />
]]></content>
	</entry>
	</feed>
