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

	<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>2004-09-21T01:44:37-04:00</updated>

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

		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-09-21T01:44:37-04:00</updated>

		<published>2004-09-21T01:44:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41069#p41069</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41069#p41069"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41069#p41069"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>set newmodes [list]</code></pre></div>Do you expect this to yield anything but an empty list?</div></blockquote></div></blockquote>Actually I set this to declare the variable $newmodes as a list, to generate a new list of modes. When the foreach loop runs it would automatically lappend the modes which aren't placed in the channel and are mentioned in the script in as $newmodes, which would then be locked and used for other stuff.<br><div class="codebox"><p>Code: </p><pre><code>foreach modelock $allmodes {  if {(![string match *$modelock* $checkmode])} {  #if {([lsearch -exact $checkmode $modelock] == -1)} {   lappend modelock $newmodes  }  }</code></pre></div>If we want to declare a variable as a list do we really need the <ul><li>?<br>set allmodes [split $clone_mlock ""]  or<br>set allmodes [list [split $clone_mlock ""]]<br><br>Secondly, [rand] generates a random number.<br>Would [rand 2] generate: 0 or 1 or 2 or just 1.<br><br>Limits for rand 2 are (0 &lt; rand 2 &lt; 2).<br>Meaning does it generate the random number with the limits or does it generate the number between the limits?</li></ul><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Tue Sep 21, 2004 1:44 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2004-09-20T16:38:29-04:00</updated>

		<published>2004-09-20T16:38:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41061#p41061</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41061#p41061"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41061#p41061"><![CDATA[
Good point user. Noted it. Thanks.<br><br>The \[$lock_modes\] is a lot more faster. 113 microseconds per iteration compared with 466 microseconds per iteration. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_mrgreen.gif" width="15" height="15" alt=":mrgreen:" title="Mr. Green"> <br><br>@ awyeah<br>In order to perform an regexp on multiple things like check of a match of foo, moo and bla in a line you should have them foo|moo|bla so that [join [split $lock_modes ""] "|"] was doing it. Got to admit that I think I was sleeping or something cos I haven't noticed it.. pff. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes">  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_mrgreen.gif" width="15" height="15" alt=":mrgreen:" title="Mr. Green"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Sep 20, 2004 4:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2004-09-20T13:17:54-04:00</updated>

		<published>2004-09-20T13:17:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41055#p41055</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41055#p41055"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41055#p41055"><![CDATA[
<blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>set newmodes [list]</code></pre></div></div></blockquote>Do you expect this to yield anything but an empty list?<blockquote class="uncited"><div>Why are you counting the length of the mode locks here? string length?</div></blockquote>The purpose of string length is to see if the number of modes matched by the regexp is == the number of lock modes (if they're all set). Why he chose to split/join instead of enclosing the modes in \[\] in the regexp, I don't know <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=2878">user</a> — Mon Sep 20, 2004 1:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-09-20T12:15:40-04:00</updated>

		<published>2004-09-20T12:15:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41052#p41052</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41052#p41052"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41052#p41052"><![CDATA[
<blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>set lock_modes "mr"set tmp [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]  if {[regexp -all [join [split $lock_modes ""] "|"] $tmp] == [string length $lock_modes]} {    return  }# continue locking the channel</code></pre></div>taken from <a href="http://www.r0x0ring.com/dl.php?id=25" class="postlink">njf.tcl</a> bla bla bla..</div></blockquote>Why are you counting the length of the mode locks here? string length?<br>and why splitting and joining them with an "|"? which would be 'm|r' hmmm, then comparing lengths with a compartor. Weird code, I don't really understand why regexp is being used here.  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><br><br>Something like this<br> if {([regexp -all "m|r" "t n"] == 2)} { ????  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused">  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Mon Sep 20, 2004 12:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2004-09-20T16:31:14-04:00</updated>

		<published>2004-09-20T11:26:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41050#p41050</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41050#p41050"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41050#p41050"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>set lock_modes "mr"set tmp [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]  if {[regexp -all [join [split $lock_modes ""] "|"] $tmp] == [string length $lock_modes]} {    return  }# continue locking the channel</code></pre></div>taken from <a href="http://www.r0x0ring.com/dl.php?id=25" class="postlink">njf.tcl</a> version 0.5 ..<br><br>edit.. actualy, on this one the thanks goes to teemu from #eggdrop @ undernet for this solution. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_mrgreen.gif" width="15" height="15" alt=":mrgreen:" title="Mr. Green"> sorry.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Sep 20, 2004 11:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-09-20T06:56:08-04:00</updated>

		<published>2004-09-20T06:56:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41044#p41044</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41044#p41044"/>
		<title type="html"><![CDATA[Channel locker (prob with string match/lsearch)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41044#p41044"><![CDATA[
Hi,<br><br>I made this following script, it works in coherance with another script kicking clones and locking the channel, this is the channel locking procedure.<br><div class="codebox"><p>Code: </p><pre><code>set clone_mlock "mR"set clone_mlockswitch "1"set clone_noticeswitch "1"set clone_notice "Testing channel locking script"set clone_mlocktime "3"bind pub m !checklock check:lockproc check:lock {nick uhost hand chan text} { global botnick clone_mlock clone_mlockswitch clone_noticeswitch clone_notice clone_mlocktime clone_mlocked  set checkmode [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]; set allmodes [split $clone_mlock ""]; putlog "Allmodes = $allmodes"  if {($clone_mlocktime == "") || ($clone_mlocktime == 0) || ($clone_mlocktime &lt; 1)} { set $clone_mlocktime 10 }  if {(![info exists clone_mlocked($chan)]) &amp;&amp; ($clone_mlockswitch == 1) &amp;&amp; ($allmodes != "")} {; set newmodes [list]   foreach modelock $allmodes { if {(![string match *$modelock* $checkmode])} { lappend modelock $newmodes } }; putlog "New modes = $newmodes"   putquick "MODE $chan +[string trim $newmodes]" -next; set clone_mlocked([join [split $chan]]) 1; putlog "Locked channel to +[string trim $newmodes]"   if {([info exists clone_mlocked($chan)]) &amp;&amp; ($clone_noticeswitch == 1) &amp;&amp; ($clone_notice != "")} {   putquick "NOTICE $chan :$clone_notice" -next; putlog "Notice = $clone_notice" } }   utimer $clone_mlocktime [list remove:flood:mlock $chan]   putlog "Removing lock in $clone_mlocktime secs"}proc remove:flood:mlock {chan} { global botnick clone_mlock clone_mlockswitch clone_mlocked  set checknewmode [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]; set newmodes [list]; set allmodes [split $clone_mlock ""]; putlog "New allmodes = $allmodes"  foreach modelock $allmodes {; if {([string match *$modelock* $checknewmode])} { lappend modelock $newmodes } }; putlog "New unlock modes = $newmodes"   if {([info exists clone_mlocked($chan)]) &amp;&amp; ($clone_mlockswitch == 1) &amp;&amp; ($allmodes != "")} {   putquick "MODE $chan -[string trim $newmodes]" -next   utimer [expr $clone_mlocktime + 5] "unset clone_mlocked($chan)"   putlog "Removed mlock -[string trim $newmodes]"   }}</code></pre></div>Here is the output of the putlogs I have put in<blockquote class="uncited"><div>&lt;bot&gt; Allmodes = m R<br>&lt;bot&gt; New modes =  <br>&lt;bot&gt; Locked channel to +<br>&lt;bot&gt; Notice = Testing channel locking script<br>&lt;bot&gt; Removing lock in 3 secs<br>&lt;bot&gt; New modes = m R<br>&lt;bot&gt; New unlock modes =  <br>&lt;bot&gt; Removed mlock -</div></blockquote>I get the value "", null for $newmodes when I try to string match, foreach modelock from the list $allmodes. Don't know what is wrong. I have tried lsearch too.<br><br>Can anyone please help me? I have made this script a little complicated so that, the bot doesn't do a mode flood and also it doesn't lock the modes which are already placed in the channel if they are given in its defined settings!<br><br>I get a null value for $newmodes, if I can get it with a value from the check:mlock procedure, then everything would be okay and would work!  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_mrgreen.gif" width="15" height="15" alt=":mrgreen:" title="Mr. Green"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Mon Sep 20, 2004 6:56 am</p><hr />
]]></content>
	</entry>
	</feed>
