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

	<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-05-28T09:47:25-04:00</updated>

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

		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-05-28T09:47:25-04:00</updated>

		<published>2003-05-28T09:47:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20868#p20868</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20868#p20868"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20868#p20868"><![CDATA[
From my first reply:<br><blockquote class="uncited"><div>...The message at this point is just a string, so the $nick part will not be replaced by the current 'nick' variable's content unless we tell tcl to parse the message for us. 'subst' is a good way to do this.</div></blockquote>I suggested this method because it's more flexible than using static keyword-&gt;value translations, but if the nick is the only variable you'll ever use in the messages the string map solution is fine <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> (subst would allow commands in the message to be performed at runtime too btw)<br><br>If you stick with the string map you should consider replacing the $ with another char to avoid having to escape it all the time (eg %nick)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Wed May 28, 2003 9:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-05-28T07:47:55-04:00</updated>

		<published>2003-05-28T07:47:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20855#p20855</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20855#p20855"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20855#p20855"><![CDATA[
thank you very much Papillon!<br><br>it finally works the way i want it to!<br><br>*cheers*<p>Statistics: Posted by Guest — Wed May 28, 2003 7:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Papillon]]></name></author>
		<updated>2003-05-28T07:38:19-04:00</updated>

		<published>2003-05-28T07:38:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20852#p20852</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20852#p20852"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20852#p20852"><![CDATA[
try this:<br><div class="codebox"><p>Code: </p><pre><code>set slaps {     "I love you, $nick!"     "\001ACTION slaps $nick back\001" } bind CTCP - ACTION action:slaps proc action:slaps {nick host handle chan keyword text} {   global slaps botnick   if { [string tolower [lindex $text 0]] == "slaps" } {     if { [string tolower [lindex $text 1]] == [string tolower $botnick]} {      putchan $chan "[string map "\$nick $nick" [lindex $slaps [rand [llength $slaps]]]]"    }   } }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=852">Papillon</a> — Wed May 28, 2003 7:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-05-28T06:59:07-04:00</updated>

		<published>2003-05-28T06:59:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20850#p20850</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20850#p20850"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20850#p20850"><![CDATA[
i read what user adviced and i tried to script it and this was what i came out with. Yes, it works fine now..it responds on slaps...but it  shows $nick instead of the user's nickname...advice?<br><div class="codebox"><p>Code: </p><pre><code>set slaps {     "I love you, $nick!"     "\001ACTION slaps $nick back\001" } bind CTCP - ACTION action:slapsproc action:slaps {nick host handle chan keyword text} {global slapsglobal botnickif { [string tolower [lindex $text 0]] == "slaps" } {if { [string tolower [lindex $text 1]] == [string tolower $botnick]} {putchan $chan "[lindex $slaps [rand [llength $slaps]]]"}}}</code></pre></div><p>Statistics: Posted by Guest — Wed May 28, 2003 6:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-05-28T04:08:17-04:00</updated>

		<published>2003-05-28T04:08:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20832#p20832</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20832#p20832"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20832#p20832"><![CDATA[
or even from:<div class="codebox"><p>Code: </p><pre><code>if {[lindex $text 2] == "slaps"} { </code></pre></div>to:<div class="codebox"><p>Code: </p><pre><code>if {[strlwr [lindex [split $text] 2]] == "slaps"} { </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed May 28, 2003 4:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-05-28T03:46:49-04:00</updated>

		<published>2003-05-28T03:46:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20830#p20830</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20830#p20830"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20830#p20830"><![CDATA[
[lindex $text 0] would be "slaps", but you need to split the text before using list commands (lindex) on it to avoid problems with speacial chars like [, { and "...<br>set text [split $text]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Wed May 28, 2003 3:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-05-27T17:15:45-04:00</updated>

		<published>2003-05-27T17:15:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20807#p20807</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20807#p20807"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20807#p20807"><![CDATA[
i'm like 5hrs new to tcl scripting. can someone please correct my mistake?<br><div class="codebox"><p>Code: </p><pre><code>set slaps {    "I love you, $nick!"    "\001ACTION slaps $nick back\001"}bind CTCP - ACTION slapsproc slaps {nick host handle chan keyword text} {global slapsglobal botnickif {[lindex $text 2] == "slaps"} {if {[lindex $text 1] == $botnick} {putserv "PRIVMSG $chan : [lindex $slaps [rand [llength $slaps]]] ."}}}</code></pre></div><p>Statistics: Posted by Guest — Tue May 27, 2003 5:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-05-20T06:27:27-04:00</updated>

		<published>2003-05-20T06:27:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20418#p20418</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20418#p20418"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20418#p20418"><![CDATA[
whoops! haha. my bad <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by Guest — Tue May 20, 2003 6:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-05-19T17:45:43-04:00</updated>

		<published>2003-05-19T17:45:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20410#p20410</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20410#p20410"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20410#p20410"><![CDATA[
Make your list of replies a tcl list. There are two ways to do this...<div class="codebox"><p>Code: </p><pre><code>set slaps {    "I love you, $nick!"    "\001ACTION slaps $nick back\001"}</code></pre></div>or<br><div class="codebox"><p>Code: </p><pre><code>set slaps [list    "I love you, \$nick!"    "\001ACTION slaps \$nick back\001"]</code></pre></div>Notice the difference...the braces ({}) add one layer of "protection" from the parser so special chars inside them (except braces) don't need to be escaped. In the first example, the escape sequence \001 will stay the way you see it, while in the second one they'll get parsed and made into the ascii char that ctcp's are enclosed in when the list is created. (You could prevent this by adding another backslash to escape the one you've got... if you really feel like it for some reason <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz">)<br><br>The $'s in the second example need to be escaped to avoid variable substitution at that point. $nick is not the nick of our victim because this list is created in the 'global namespace' before the proc using the messages is even triggered.<br><br>Now for the proc (that would best be triggered by a ctcp bind)...<br><br>Inside the proc body you'll have to import the variable to be able to use it (by using 'global slaps') or address it directly using a fully qualified namespace path (::slaps). Then use 'lindex' combined with 'rand' or 'expr rand()' and 'llength' to pick a random message. The message at this point is just a string, so the $nick part will not be replaced by the current 'nick' variable's content unless we tell tcl to parse the message for us. 'subst' is a good way to do this.<br><br>That's about all you need to know<br>...have fun.<br><br>PS: I never slapped botnick...that's a lie!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon May 19, 2003 5:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2003-05-19T17:43:01-04:00</updated>

		<published>2003-05-19T17:43:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=20409#p20409</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=20409#p20409"/>
		<title type="html"><![CDATA[Request : Simple Action Reply Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=20409#p20409"><![CDATA[
can someone help me code a simple tcl script that responds randomly to actions please?<br><br>example:<br><br>* user slaps botnick.<br>* botnick slaps user with a [random item]<br><br>example 2:<br><br>* user slaps botnick.<br>botnick : [random respond]<br><br><br>Thanks in advance!<p>Statistics: Posted by Guest — Mon May 19, 2003 5:43 pm</p><hr />
]]></content>
	</entry>
	</feed>
