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

	<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-27T09:12:41-04:00</updated>

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

		<entry>
		<author><name><![CDATA[FallFromGrace]]></name></author>
		<updated>2011-01-27T09:12:41-04:00</updated>

		<published>2011-01-27T09:12:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95855#p95855</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95855#p95855"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95855#p95855"><![CDATA[
it's not a best solution, but i'll try it, thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10083">FallFromGrace</a> — Thu Jan 27, 2011 9:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-01-27T06:41:27-04:00</updated>

		<published>2011-01-27T06:41:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95854#p95854</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95854#p95854"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95854#p95854"><![CDATA[
<blockquote class="uncited"><div>i have tried to do such thing:<br><div class="codebox"><p>Code: </p><pre><code>set x "first"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}set x "second"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}set x "third"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}</code></pre></div>But it doesnt work too! It binds all of these commands to ".third". How can i fix it?</div></blockquote>How is that anything like I showed you. Those { } braces suppress execution of substitution. Until the time the bind is triggered and processed, at that point the last value of $x will be used. This is why only the last entry for you works. Stop using that bind...{ } method. Use like I have below:<div class="codebox"><p>Code: </p><pre><code># init rs as a list for testingset [list "first" 1 "second" 2 "third" 3]foreach {cmd priv} $rs {      if {$priv &lt; 2} {         bind pub - ".$cmd" [list "$cmd" pub]      } elseif {$priv &gt; 0} {         bind msg - ".$cmd" [list "$cmd" msg]      }}proc first {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "first"}proc second {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "second"}proc third {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "third"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Thu Jan 27, 2011 6:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[FallFromGrace]]></name></author>
		<updated>2011-01-27T06:22:23-04:00</updated>

		<published>2011-01-27T06:22:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95853#p95853</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95853#p95853"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95853#p95853"><![CDATA[
i have tried to do such thing:<br><div class="codebox"><p>Code: </p><pre><code>set x "first"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}set x "second"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}set x "third"bind pub - ".$x" {$x $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}</code></pre></div>But it doesnt work too! It binds all of these commands to ".third". How can i fix it?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10083">FallFromGrace</a> — Thu Jan 27, 2011 6:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-01-26T21:09:34-04:00</updated>

		<published>2011-01-26T21:09:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95850#p95850</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95850#p95850"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95850#p95850"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>foreach {cmd priv} $rs {      if {$priv &lt; 2} {         bind pub - ".$cmd" [list "$cmd" pub]      } elseif {$priv &gt; 0} {         bind msg - ".$cmd" [list "$cmd" msg]      }}proc first {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "first"}proc second {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "second"}proc third {type nick uhost hand chan {text ""}} {  # type = msg, rearrange arguments  if {[string equal "msg" $type]} { set text $chan ; set chan $nick }  putlog "third"}</code></pre></div>This will work. Since some of your commands also have empty text field. Let's simply add a "type" to each bind that signifies to the procedures which has invoked it. Simple. <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=8138">speechles</a> — Wed Jan 26, 2011 9:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[FallFromGrace]]></name></author>
		<updated>2011-01-26T20:03:20-04:00</updated>

		<published>2011-01-26T20:03:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95849#p95849</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95849#p95849"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95849#p95849"><![CDATA[
"proc first" is a sample, i have another names for procedures =)<br><br>I can't use your way to check $text == "", some of my commands should work both with text and without it.<br><br>Any way, "bind pub - ".$cmd" {$cmd $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}" - won't work. As I said, it will only bind the last proc. <br><br>I think it's a special block of code, and I can't just write "$cmd" there.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10083">FallFromGrace</a> — Wed Jan 26, 2011 8:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-01-26T18:35:59-04:00</updated>

		<published>2011-01-26T18:35:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95848#p95848</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95848#p95848"/>
		<title type="html"><![CDATA[Re: Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95848#p95848"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>proc <strong class="text-strong">frist</strong> {nick uhost hand chan text} {</div></blockquote></div></blockquote>To start off, you do not have a "first" procedure. It's actually frist. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>And secondly, why don't you do it this way?<br>This makes it easier for pub and msg to use the same procedure. Based on the amount of args passed the procedure can reform it's arguments to make commands easier. If it's a private message $chan will become their $nick. This makes it easier to script events as you only need to remember 1 place to send replies, $chan. Rather than guessing whether it was a pub or msg bind passed to each procedure. This way removes the guessing.<div class="codebox"><p>Code: </p><pre><code>foreach {cmd priv} $rs {      if {$priv &lt; 2} {         bind pub - ".$cmd" $cmd      } elseif {$priv &gt; 0} {         bind msg - ".$cmd" $cmd      }}proc first {nick uhost hand chan {text ""}} {  # no text = msg, rearrange arguments  if {![string length $text]} { set text $chan ; set chan $nick }  putlog "first"}proc second {nick uhost hand chan {text ""}} {  # no text = msg, rearrange arguments  if {![string length $text]} { set text $chan ; set chan $nick }  putlog "second"}proc third {nick uhost hand chan {text ""}} {  # no text = msg, rearrange arguments  if {![string length $text]} { set text $chan ; set chan $nick }  putlog "third"}</code></pre></div>Your code corrected would look like this, #comments denote the fixes.<div class="codebox"><p>Code: </p><pre><code>foreach {cmd priv} $rs {      if {$priv != 2} {         bind pub - ".$cmd" {$cmd $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}      } elseif {$priv != 0} {         # pass the nickname as the channel, makes messaging easier         bind msg - ".$cmd" {$cmd $_msg1 $_msg2 $_msg3 $_msg1 $_msg4; #}      }}# corrected mispelling of firstproc first {nick uhost hand chan text} {  putlog "first"}proc second {nick uhost hand chan text} {  putlog "second"}proc third {nick uhost hand chan text} {  putlog "third"}</code></pre></div>Either should work equally the same.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Wed Jan 26, 2011 6:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[FallFromGrace]]></name></author>
		<updated>2011-01-27T06:04:08-04:00</updated>

		<published>2011-01-26T18:21:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95847#p95847</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95847#p95847"/>
		<title type="html"><![CDATA[Dynamic binds...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95847#p95847"><![CDATA[
I have a commands stored in mysql database. I want to bind them dynamically.<br><br>There is no problem if i do this:<div class="codebox"><p>Code: </p><pre><code>set rs [mysqlsel $sql "SELECT command, private FROM commands " -flatlist]# f.e. rs = "first 1 second 1 third 1"# my commands starts with a dot# priv is a switch (0 = channel only, 1 = both, 2 = private only)foreach {cmd priv} $rs {if {$priv != 2} {bind pub - ".$cmd" $cmd} elseif {$priv != 0} {bind msg - ".$cmd" priv:$cmd}}proc first {nick uhost hand chan text} {  if {$text == ""} {    putlog "first" } else {    putlog "first, text = $text" }}proc second {nick uhost hand chan text} {  if {$text == ""} {    putlog "second" } else {    putlog "second, text = $text" }}proc third {nick uhost hand chan text} {  if {$text == ""} {    putlog "third" } else {    putlog "third, text = $text" }}proc priv:first {nick uhost hand text} {  if {$text == ""} {    putlog "first" } else {    putlog "first, text = $text" }}proc priv:second {nick uhost hand text} {  if {$text == ""} {    putlog "second" } else {    putlog "second, text = $text" }}proc priv:third {nick uhost hand text} {  if {$text == ""} {    putlog "third" } else {    putlog "third, text = $text" }}</code></pre></div>But i have read a thread about binding private and channel commands to the same proc: <a href="http://forum.egghelp.org/viewtopic.php?t=11796" class="postlink">http://forum.egghelp.org/viewtopic.php?t=11796</a><br><br>And i want to make it work:<div class="codebox"><p>Code: </p><pre><code>foreach {cmd priv} $rs {if {$priv != 2} {bind pub - ".$cmd" {$cmd $_pub1 $_pub2 $_pub3 $_pub4 $_pub5; #}} elseif {$priv != 0} {bind msg - ".$cmd" {$cmd $_msg1 $_msg2 $_msg3 "" $_msg4; #}}}proc first {nick uhost hand chan text} {  if {$text == ""} {    putlog "first" } else {    putlog "first, text = $text" }}proc second {nick uhost hand chan text} {  if {$text == ""} {    putlog "second" } else {    putlog "second, text = $text" }}proc third {nick uhost hand chan text} {  if {$text == ""} {    putlog "third" } else {    putlog "third, text = $text" }}</code></pre></div>Bot binds ".first", ".second" and ".third" commands to a last bind (proc third), and i only see "third" as an universal answer for an all of these commands.<br><br>I think, there is something wrong with my syntax.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10083">FallFromGrace</a> — Wed Jan 26, 2011 6:21 pm</p><hr />
]]></content>
	</entry>
	</feed>
