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

	<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>2009-10-20T19:44:16-04:00</updated>

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

		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-10-20T19:44:16-04:00</updated>

		<published>2009-10-20T19:44:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90587#p90587</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90587#p90587"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90587#p90587"><![CDATA[
<blockquote class="uncited"><div>My preference is also to set a user defined channel flag. It permits you you to switch a script on/off in any channel without changing a script's configuration and rehashing.</div></blockquote>Good.<br>Thanks.<br><blockquote class="uncited"><div>As for different methods/syntax/commands achieving the same result. I would say such things are commonplace in most if not all languages. I would tend to choose the simplest, though sometimes I might have a favourite without there necessarily being an obvious reason. I suppose 'elegance' also creeps into it somewhere. The most important issue is that when you look at a piece of code you previously wrote, you can instantly recognise what it is doing.</div></blockquote>oh. ok.  <br>I guess I was more thinking of the "unknown"... that if I do it this way instead of that way,  and both seem to work now....   then later on down the road it returns to bite me in the butt because I didn't know any better, as to which way to do it.  If and when it happens, I'll just have to deal with it then.   <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Thanks for your explanation and advice.<br><br><br><blockquote class="uncited"><div>It is good practice for a proc to return a value when the code has finished execution, even if the return value is unused. </div></blockquote>ok.<br><blockquote class="uncited"><div>I generally use 'return 0' though on many occasions you will see simply 'return' or even 'return 1'. There is one important factor to consider. For some bind procs, the return value may be crucial. These can be found in tcl-commands.html under the heading 11 Bind b Return values. ALWAYS take account of these as not doing so can lead to unexpected results.</div></blockquote>I've run afoul of this, I believe.  Logging ceased.   As I recall, return 1  did it.   <br>I was wondering if this was what you were going to say,  as the reason, when I asked. <br>I was thinking you might say that return 0 is a general good idea, when possible.<br>Thanks for your comments.<br><br><br>Duly armed with this info, and some ideas to see if I can work out -  I shall return to the drawing board.      <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=10420">willyw</a> — Tue Oct 20, 2009 7:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-20T12:51:04-04:00</updated>

		<published>2009-10-20T12:51:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90586#p90586</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90586#p90586"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90586#p90586"><![CDATA[
My preference is also to set a user defined channel flag. It permits you you to switch a script on/off in any channel without changing a script's configuration and rehashing.<br><br>As for different methods/syntax/commands achieving the same result. I would say such things are commonplace in most if not all languages. I would tend to choose the simplest, though sometimes I might have a favourite without there necessarily being an obvious reason. I suppose 'elegance' also creeps into it somewhere. The most important issue is that when you look at a piece of code you previously wrote, you can instantly recognise what it is doing.<br><br>It is good practice for a proc to return a value when the code has finished execution, even if the return value is unused. I generally use 'return 0' though on many occasions you will see simply 'return' or even 'return 1'. There is one important factor to consider. For some bind procs, the return value may be crucial. These can be found in tcl-commands.html under the heading 11 Bind b Return values. ALWAYS take account of these as not doing so can lead to unexpected results.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Tue Oct 20, 2009 12:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-10-20T11:59:08-04:00</updated>

		<published>2009-10-20T11:59:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90585#p90585</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90585#p90585"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90585#p90585"><![CDATA[
Thanks for the reply, and examples.<br><br><blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>...    if {[channel get $chan uflag]} {        # code here    }    return 0}</code></pre></div>OR<br><div class="codebox"><p>Code: </p><pre><code>...    if {[lsearch -exact [split [string tolower $vTestChans]] [string tolower $chan]] != -1} {        # code here    }    return 0}</code></pre></div>The first example requires '.chanset #channelname +uflag' in the bot's partyline for each channel you require the script to function on.<br><br>The second example could be made a little simpler by using the -nocase option for the lsearch command, but this option was only made available on Tcl 8.5 therefore would not work for older installations.</div></blockquote>If one style is just as good and acceptable as the other,  I'm going with the first one then.  Where the flag is set via .chanset, etc.    For no other reason than personal preference.    <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>You did cause me to go looking in tcl-commands.doc though.<br>I found the command you are using to check for the flag -  channel get.<br>Interesting.<br><br>The command I'd found used in other scripts, was like this:<br>if {([lsearch -exact [channel info $chan] {+theflag}] != -1)} {<br><br>The     channel  info       command.<br><br>Is there a reason to choose one method (command) vs. the other?  or just personal preference? <br><br>Also, and again in the interest of learning good practice:<br>I     return 0        in there.<br>What is the reasoning behind that?     ... thanks<br><br><br><blockquote class="uncited"><div>The most likely reason for the lack of response is that you pretty much answered your own question. It is always a good idea to study other scripts.</div></blockquote>But it is reassuring to get feedback and an opinion from someone 'live', that didn't write the script that I was examining.   <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">     <br>Thank you, ... I appreciate your time.<br><br>By the way,  the I believe I got my multi-channel (selectable chans) join counter script working!   <br>Of course, now I've thought of something I want to modify in it......<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Tue Oct 20, 2009 11:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-19T15:45:52-04:00</updated>

		<published>2009-10-19T15:45:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90578#p90578</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90578#p90578"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90578#p90578"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>setudef flag uflagbind PUB - !test1 pTestProc1proc pTestProc1 {nick uhost hand chan text} {    if {[channel get $chan uflag]} {        # code here    }    return 0}</code></pre></div>OR<br><div class="codebox"><p>Code: </p><pre><code>set vTestChans "#chan1 #chan2 #chan3"bind PUB - !test2 pTestProc2proc pTestProc2 {nick uhost hand chan text} {    global vTestChans    if {[lsearch -exact [split [string tolower $vTestChans]] [string tolower $chan]] != -1} {        # code here    }    return 0}</code></pre></div>The first example requires '.chanset #channelname +uflag' in the bot's partyline for each channel you require the script to function on.<br><br>The second example could be made a little simpler by using the -nocase option for the lsearch command, but this option was only made available on Tcl 8.5 therefore would not work for older installations.<br><br>The most likely reason for the lack of response is that you pretty much answered your own question. It is always a good idea to study other scripts.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Mon Oct 19, 2009 3:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-10-19T10:58:15-04:00</updated>

		<published>2009-10-19T10:58:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90574#p90574</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90574#p90574"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90574#p90574"><![CDATA[
No replies?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Mon Oct 19, 2009 10:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2009-10-17T12:46:14-04:00</updated>

		<published>2009-10-17T12:46:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90537#p90537</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90537#p90537"/>
		<title type="html"><![CDATA[How to make a script selectable multi-channel]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90537#p90537"><![CDATA[
Hello,<br><br>Not sure how to classify myself....  I can do basic scripts, and have fun figuring out how to get them to work.<br>Beginner?<br><br><br>I'd like to learn a good method of making scripts multi-channel.   NOT all channels that the bot is on though -  but be able to have the script operate in some channels that I select.<br><br>An example of a script that I'd like to modify to become multi-channel, is:<br><a href="http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&amp;id=821" class="postlink">http://www.egghelp.org/cgi-bin/tcl_arch ... oad&amp;id=821</a><br>It is named  count.tcl  by caesar.   v.0.1  11/04/2003<br><br>No doubt there are other scripts out there, that do what this one does, and are already multi-channel.    But I want to learn a good method, and this script is not too complicated.   And,  I would like a nice multi-channel counter script (maintain seperate join counts on a per channel basis)  anyway.   <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>I thought it might be a good place to start.<br><br>I found one method, somewhere,  that set channels by name, in an array.<br>It just didn't feel right.<br><br>But elsewhere, - - in this script:   <a href="http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&amp;id=259" class="postlink">http://www.egghelp.org/cgi-bin/tcl_arch ... oad&amp;id=259</a><br>peak.tcl  1.8  25/07/2004  FireEgl<br>I found that he does it with setudef   and uses:<br>if {[lsearch -exact [channel info $chan] {+peak}] != -1}<br><br>When I also found that method in the google script by incith ( That is a GREAT script! ) ,  I was encouraged.<br><br>First question:   Before I waste a lot of time studying it, and trying to learn to implement this method -   is this a good method to learn?<br><br>Next question:  Using the search engine here in the forum,  I didn't find any posts that addressed this.   If you have anything, anywhere to direct me to,  for more reading on this,   please post a link.   <br><br>Last:  Any other comments to get me going in the right direction will be appreciated.<br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sat Oct 17, 2009 12:46 pm</p><hr />
]]></content>
	</entry>
	</feed>
