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

	<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>2008-05-21T10:35:56-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Papillon]]></name></author>
		<updated>2008-05-21T10:35:56-04:00</updated>

		<published>2008-05-21T10:35:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83061#p83061</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83061#p83061"/>
		<title type="html"><![CDATA[Modifying decision.tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83061#p83061"><![CDATA[
I got really bored, so redesigned it abit. Don't shoot me if any errors occur as I am unable to test it on an eggdrop and my tcl abilities might be a bit rusty<div class="codebox"><p>Code: </p><pre><code>set channl "#chaneelyouwant"bind msg - \[ making_choicesproc making_choices {nick host hand arg} {set arg [fixthearg "$arg"]set opts [regexp -all {\[\]} $arg]if {[lindex [split $arg] 0] == {\[\]} || $opts == 1} { return }set inx [lsearch -all [split $arg] {\[\]}]set ran [rand $opts]set showlist [list ""]for {set st 0} {$st &lt;= [expr $opts -1]} {incr st} {set putin ""if {$st == [expr $opts -1]} { set inx_str [join [lrange [split $arg] [expr [lindex $inx $st] +1] end]]} else {set inx_str [join [lrange [split $arg] [expr [lindex $inx $st] +1] [expr [lindex $inx [expr $st +1]] -1]]]}if {$inx_str == {}} { continue }if {$st == $ran} { set putin x }lappend showlist [join "\[$putin\] $inx_str"]}puthelp "PRIVMSG $::channl :[join $showlist]"}proc fixthearg {arg} {regsub -all {\[\]} "\[$arg" " \[\] " argregsub -all {  } $arg { } argreturn "$arg"}</code></pre></div>It should be able to handle abit more faulty inputs... hopefully <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=852">Papillon</a> — Wed May 21, 2008 10:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[droune]]></name></author>
		<updated>2008-05-21T06:52:41-04:00</updated>

		<published>2008-05-21T06:52:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83054#p83054</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83054#p83054"/>
		<title type="html"><![CDATA[Modifying decision.tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83054#p83054"><![CDATA[
<blockquote class="uncited"><div>your problem most likely is in the very first line<div class="codebox"><p>Code: </p><pre><code>set channl #channel </code></pre></div>tcl interpret everything following # on a line as a comment, so you need to do<div class="codebox"><p>Code: </p><pre><code>set channl "#channel" </code></pre></div>for $channl not to be an empty variable</div></blockquote>Ahh, so that's the problem. It works now. Thanks a lot <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=9940">droune</a> — Wed May 21, 2008 6:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Papillon]]></name></author>
		<updated>2008-05-21T06:32:35-04:00</updated>

		<published>2008-05-21T06:32:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83053#p83053</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83053#p83053"/>
		<title type="html"><![CDATA[Modifying decision.tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83053#p83053"><![CDATA[
your problem most likely is in the very first line<div class="codebox"><p>Code: </p><pre><code>set channl #channel </code></pre></div>tcl interpret everything following # on a line as a comment, so you need to do<div class="codebox"><p>Code: </p><pre><code>set channl "#channel" </code></pre></div>for $channl not to be an empty variable<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=852">Papillon</a> — Wed May 21, 2008 6:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[droune]]></name></author>
		<updated>2008-05-20T17:33:57-04:00</updated>

		<published>2008-05-20T17:33:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83046#p83046</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83046#p83046"/>
		<title type="html"><![CDATA[Modifying decision.tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83046#p83046"><![CDATA[
Hello.<br><br>I found this great <a href="http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&amp;id=1525" class="postlink"> script</a> which can make some decisions for me. It works like this:<br><br>&lt;user&gt; [ ] option 1 [ ] option 2 [ ] option 3<br>&lt;bot&gt; [x] option 1 [ ] option 2 [ ] option 3<br><br>The idea is great but I'd like to modify it a bit. The best way to avoid channel flooding is to set the user input on private messages and the actual output on the channel. Example:<br><br>User sends a private message to bot: "[ ] option 1 [ ] option 2 [ ] option 3"<br>Bot chooses randomly an option and prints the output on #channel:<br>&lt;bot&gt; user on private: [ ] option 1 [x] option 2 [ ] option 3<br><br>So I modified the code like this (Note: I haven't touched the actual text manipulating. I've only changed the first four lines and the puthelp-line):<br><div class="codebox"><p>Code: </p><pre><code>set channl #channelbind msg - \[ proc:decisionproc proc:decision {nick host hand arguments} {global channl   set arguments [split $arguments]   set count 1   set klammer_count 0   if {([lindex $arguments 0] == "]") || ([string first "]" [lindex $arguments 0]] == 0)} {      incr klammer_count   } else {      return   }   while {$count != [llength $arguments]} {      if {[lindex $arguments $count] == "\["} {         set tmp $count         incr tmp         if {([lindex $arguments $tmp] == "]") || ([string first "]" [lindex $arguments $tmp]] == 0)} {            incr klammer_count         }      }      incr count   }   set count 0   set myrand [rand $klammer_count]   set klammer_count 0   if {$myrand == 0} {      set output "\[x"      while {$count != [llength $arguments]} {         set output "$output[lindex $arguments $count] "         incr count      }   } else {      set output "\["      while {$count != [llength $arguments]} {         if {[lindex $arguments $count] == "\["} {            set tmp $count            incr tmp            if {([lindex $arguments $tmp] == "]") || ([string first "]" [lindex $arguments $tmp]] == 0)} {               incr klammer_count            }         }         if {$klammer_count == $myrand} {            if {([lindex $arguments $count] == "]") || ([string first "]" [lindex $arguments $count]] == 0)} {               set output "[string range $output 0 end]x"            } else {               set output "$output "            }         } else {            set output "$output "         }         set output "$output[lindex $arguments $count]"         incr count      }   }   puthelp "PRIVMSG $channl :$nick on private: '$output'"}</code></pre></div>But the code doesn't seem to work. At first I thought the problem was in the bind part as I'm using MSG, but it treats everything identically as PUB.<br><br>So could someone help me? I'm really running out of ideas. Thanks in advance.<br><br>P.S. My first post <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=9940">droune</a> — Tue May 20, 2008 5:33 pm</p><hr />
]]></content>
	</entry>
	</feed>
