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

	<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>2011-01-08T13:40:30-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-01-08T13:40:30-04:00</updated>

		<published>2011-01-08T13:40:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95585#p95585</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95585#p95585"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95585#p95585"><![CDATA[
Actually, if you use "args" as the last argument in a proc-definition, it is guaranteed to be a valid tcl-list, with one item for each parameter (if any) supplied (when the proc is invoked).<br><br>Using lassign should not alter the scope of the source, as this is expected to be a list, not a variable containing a list.<br>The scope of the variables set by lassign depends on the names you provide with the command; do they include any namespace paths? (::myvar ::somespace::myvar), is the variable linked to a different execution level using upvar or global?, and so on.<br><br>Regarding your code; I doubt that does what you intended; $args would never be equal to the string "4". You should use the llength command to get the length of the list. Also, VarA is not set prior either "set $VarA" lines, causing an error. I assume you actually intended to set a value to the variable VarA, not a variable named by the contents of VarA (remove the $-sign).<div class="codebox"><p>Code: </p><pre><code>bind pub - !test commandbind msg - !test commandproc command {nick args} {    set arg [lindex $args end]    if {[llength $args] == 4} {        #Triggered by the pub-binding        set VarA {PRIVMSG}    } else {        #Triggered by the msg-binding        set VarA {NOTICE}    }    putquick "$VarA $nick :Command Successful! you said $arg"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Jan 08, 2011 1:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2011-01-08T02:19:01-04:00</updated>

		<published>2011-01-08T02:19:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95579#p95579</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95579#p95579"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95579#p95579"><![CDATA[
hi thommey, nml, speechles and gang..<br><br><br>Again, this place is some of the best minds for eggdrop!<br><br>the example you gave me didn't fix the issue, however it did offer a working example- which taught me something I didn't even realize...<br><br>args can be "list"ed!<br><br>the reason the example didn't work was because I needed arg- and once it got lassigned, it no-longer was a local varable..<br><br>I solved my problem with a simple line though...<br><br>although my code where I used the "fix" is too lengthy to display.. I'll diosplay a simple example instead..<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !test commandbind msg - !test commandproc command {nick args} {    set arg [lindex $args end-0]    if {($args == "4")} {        set $VarA {PRIVMSG}    } else {        set $VarA {NOTICE}    }    putquick "$VarA $nick :Command Successful! you said $arg"}</code></pre></div>this is very close to what I did to fix my code to work.. (I added the end so it makes sense in this example)<br><br>nonetheless it works! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <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=10318">dj-zath</a> — Sat Jan 08, 2011 2:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[thommey]]></name></author>
		<updated>2011-01-06T11:25:47-04:00</updated>

		<published>2011-01-06T11:25:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95560#p95560</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95560#p95560"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95560#p95560"><![CDATA[
Avoiding "args" because it's special is just the generic advice for beginners who use it without being aware of the special meaning instead of "text" or something else. <br><br>You can read about it <a href="http://www.invece.org/tclwise/more_on_procedures.html" class="postlink">here (chapter 7.5)</a> and/or <a href="http://www.tcl.tk/man/tcl8.5/tutorial/Tcl12.html" class="postlink">here</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9830">thommey</a> — Thu Jan 06, 2011 11:25 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2011-01-05T16:10:32-04:00</updated>

		<published>2011-01-05T16:10:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95554#p95554</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95554#p95554"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95554#p95554"><![CDATA[
thanks for the heads-up thommey!<br><br>yeah, I know about using args..  but I was told to -avoid- using args (whenever possable)<br><br>I'm looking at your exmaple and (re)teaching myself the basics again <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>again, thanks for the example <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <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=10318">dj-zath</a> — Wed Jan 05, 2011 4:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[thommey]]></name></author>
		<updated>2010-12-31T23:46:39-04:00</updated>

		<published>2010-12-31T23:46:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95528#p95528</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95528#p95528"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95528#p95528"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>bind pub - !cmd docmdbind msg - cmd docmdproc docmd {args} {# for pub we have 5 arguments, for msg it's 4  if {[llength $args] == 5} {# &lt;=Tcl8.4 compatible way (instead of lassign):#  foreach {nick host hand chan text} $args break    lassign $args nick host hand chan text    set replytarget $chan  } elseif {[llength $args] == 4} {# &lt;=Tcl8.4 compatible way (instead of lassign):#  foreach {nick host hand text} $args break    lassign $args nick host hand text    set replytarget $nick  } else {    error "Weird call of arguments"  }  putmsg $replytarget "Worked!"}</code></pre></div>Or some generic wrapper if you know your existing pub cmd procs can deal with a "fake" channel and don't require a real one (to check for [isop] etc. and just need it for replying):<div class="codebox"><p>Code: </p><pre><code>bind pub - !cmd "wrap pub:cmd"bind msg - cmd "wrap pub:cmd"proc wrap {procname args} {  if {[llength $args] == 5} {    lassign $args nick host hand chan text  } else {    lassign $args nick host hand text    set chan $nick  }  $procname $nick $host $hand $chan $text}</code></pre></div>You can figure out other stuff you can do, just read tutorials that mention "args"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9830">thommey</a> — Fri Dec 31, 2010 11:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2010-12-31T22:36:42-04:00</updated>

		<published>2010-12-31T22:36:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95527#p95527</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95527#p95527"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95527#p95527"><![CDATA[
thanks willy:<br><br>though I have allready read that file over a few times.. it wasn't much help in this case, however..<br><br>but, in playing around..<br><br>if I set:<br><div class="codebox"><p>Code: </p><pre><code>{nick uhost hand chan arg}</code></pre></div>it works in a <em class="text-italics">bind pub</em><br><br>and if I set:<br><div class="codebox"><p>Code: </p><pre><code>{nick uhost hand arg}</code></pre></div>it works in a <em class="text-italics">bind msg</em><br><br>the trick is to get it to work in <em class="text-italics">BOTH</em> a pub and a msg... but, if I can't do that.. (without repeating the command sets.. they are HUUUUUGE) I can live with just the msg bind.. <br><br>again, thanks for the nudge!<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <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=10318">dj-zath</a> — Fri Dec 31, 2010 10:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2010-12-31T22:17:07-04:00</updated>

		<published>2010-12-31T22:17:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95526#p95526</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95526#p95526"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95526#p95526"><![CDATA[
hi there Willy!<br><br>and thanks for the reply<br><br>I have been screwing around with this as we speak..<br><br>II have changed it to  "proc nick args" and it works.. but.. that was just the "test command"  and now the actual command I need working..<br><br>I'll try to explain:<br><br>I need to be able to have users send pub commands with an arg<br><br>example:<br><br>!search tainted love<br><br>and I need them to be able to do it in a "msg window" as well..<br><br>since the bot returns the queryt in a message window, it woud only make sense that users can do that there as well...<br><br>the script to do this, in itself (I mean the script that gets the data and processess the query) is quite complex and involved...  and the bext way to explain it is to demo it for you.. (that can be done simply by coming to my chat at <a href="http://ustream.tv/channel/piezo" class="postlink">http://ustream.tv/channel/piezo</a> and typing !search &lt;song name&gt; I'm there now working on the thing...<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <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=10318">dj-zath</a> — Fri Dec 31, 2010 10:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2010-12-31T22:05:22-04:00</updated>

		<published>2010-12-31T22:05:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95525#p95525</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95525#p95525"/>
		<title type="html"><![CDATA[Re: getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95525#p95525"><![CDATA[
<blockquote class="uncited"><div>...<div class="codebox"><p>Code: </p><pre><code>proc TestMsg {nick uhost hand chan arg} {    putserv "PRIVMSG $nick :Command Successful!"}</code></pre></div></div></blockquote>chan?<br>what chan?<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><br><br>It is a command that responds to a /msg to the  bot.<br>No channel is involved at all.<br><br><blockquote class="uncited"><div>returns the error:<br><br>"wrong number of arguments: should be TestMsg nick uhost hand chan arg"<br><br>and, that.. as they say, is that!<br><br>so, what am I doing wrong? (sheepish grin)<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>proc TestMsg {nick uhost hand chan arg} <br><br><br>Go here:<br><a href="http://www.eggheads.org/support/egghtml/1.6.20/tcl-commands.html" class="postlink">http://www.eggheads.org/support/egghtml ... mands.html</a><br>and text search to find:<br>bind msg<br>and you'll find:<br>procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;text&gt;<br><br>I hope this helps.<br><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> — Fri Dec 31, 2010 10:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2011-01-08T01:43:05-04:00</updated>

		<published>2010-12-31T21:47:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95523#p95523</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95523#p95523"/>
		<title type="html"><![CDATA[[SOLVED!] getting msg binds to work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95523#p95523"><![CDATA[
I know this one should be simple, but I'm not quite grasping it..<br><br>I can get <em class="text-italics">bind pub</em>s to work all-day-long...<br><br>but this:<br><div class="codebox"><p>Code: </p><pre><code>bind msg -|- !test TestMsg</code></pre></div>and then:<br><div class="codebox"><p>Code: </p><pre><code>proc TestMsg {nick uhost hand chan arg} {    putserv "PRIVMSG $nick :Command Successful!"}</code></pre></div>returns the error:<br><br>"wrong number of arguments: should be TestMsg nick uhost hand chan arg"<br><br>and, that.. as they say, is that!<br><br>so, what am I doing wrong? (sheepish grin)<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <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=10318">dj-zath</a> — Fri Dec 31, 2010 9:47 pm</p><hr />
]]></content>
	</entry>
	</feed>
