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

	<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>2003-02-25T05:53:53-04:00</updated>

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

		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-25T05:53:53-04:00</updated>

		<published>2003-02-25T05:53:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=17044#p17044</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=17044#p17044"/>
		<title type="html"><![CDATA[Legalchan proc and other code improvements?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=17044#p17044"><![CDATA[
First off, you are handling strings and list incorrectly.<br><br>See the FAQ forum, for more details on converting the string to a list, before using the "lindex" command.<br><br>Another issue. Do not use the unset command on the variables defined in the proc definition, there is no need. Simply overwrite them.<br><br>OK, for your points.<br><br>1: There is no need to do this. It can and may break things. You should do this in the per:say proc.<br><br>However, you can use the uplevel command, though it's not as easy as you think, due to Tcl evaluation.<br><div class="codebox"><p>Code: </p><pre><code>proc legalchan { text } {   if { [string index [lindex [split $text] 0] 0] == "#" &amp;&amp; [botonchan [lindex [split $text] 0]] } {     uplevel 1 [list set chan [lindex [split $text] 0]]    return 1  } else {     return 0   } }</code></pre></div>2: The botonchan is working perfectly fine, it's the way you use it thats incorrect.<br><br>It's likely that either the way you handle lists, or somthing else is causing this. Though the documentation doesn't say this, it may also return a error, if the bot isn't support to be monitoring that channel (in which case, there are other command ypu need too).<br><br>3: I don't understand why you need a reset command, or why you used unset int he first place.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Feb 25, 2003 5:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[scr0llwheel]]></name></author>
		<updated>2003-02-24T20:54:47-04:00</updated>

		<published>2003-02-24T20:54:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=17026#p17026</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=17026#p17026"/>
		<title type="html"><![CDATA[Legalchan proc and other code improvements?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=17026#p17026"><![CDATA[
Ok, first take a look at the code I've got so far:<div class="codebox"><p>Code: </p><pre><code>proc per:say { nick host handle chan text } {  if { [legalchan $text] } {    unset chan    set chan [lindex $text 0]    set text_ [lrange $text 1 end]    unset text    set text $text_  }  putquick "PRIVMSG $chan :[join [lrange $text 0 end]]"  mydebug "Said \"$text\" in $chan requested by $nick ($handle)"}proc legalchan { text } {  if { [string index [lindex $text 0] 0] == "#" &amp;&amp; [botonchan [lindex $text 0]] } {    return 1  } else {    return 0  }}</code></pre></div>Now, there are three things:<br>1) I want to make it so the unsetting and setting of variables is in the legalchan proc and will return those values back into the per:say proc. I've also seen something like this related to "return -code" and "upvar" (so I don't have to pass the variables to the legalproc ?)<br>2) It's not working if I do something like "?say #adsf test" (and the bot isn't on #asdf). I get the error of "Tcl error [per:say]: illegal channel: #asdf." It seems the "botonchan" check isn't working?<br>3) Is there a "reset" command so I don't have to do unset/set and especially with the $text variable? (unset/set as another name/set again).<br><br>Thanks,<br>scr0llwheel<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2465">scr0llwheel</a> — Mon Feb 24, 2003 8:54 pm</p><hr />
]]></content>
	</entry>
	</feed>
