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

	<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-04-26T14:56:40-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-26T14:56:40-04:00</updated>

		<published>2011-04-26T14:56:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96780#p96780</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96780#p96780"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96780#p96780"><![CDATA[
That piece may be a little beyond my means, then.<br><br>I really do appreciate all of the help you've given me with all of my requests! If there was a way to bump your ID to "guru" status, I would cast my vote! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Thank you again, for all of your help and patience. I've learned a lot about TCL.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Tue Apr 26, 2011 2:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-04-26T14:48:59-04:00</updated>

		<published>2011-04-26T14:48:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96779#p96779</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96779#p96779"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96779#p96779"><![CDATA[
Oh, overlooked that part..<br>In this case, $::item would only hold the value of the last item of $triggerwords. You would have to use a similar foreach-loop within the proc to test each item in the list. You would also have to use break or return to prevent multiple responses if one line contains several of the triggers.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 26, 2011 2:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-26T14:45:42-04:00</updated>

		<published>2011-04-26T14:45:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96778#p96778</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96778#p96778"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96778#p96778"><![CDATA[
Ah, I see.<br><br>I dropped the "then" from the statement. The part that concerns me is the string match:<br><div class="codebox"><p>Code: </p><pre><code>if {[string match -nocase -- "*$::item*" $text]} { </code></pre></div>Is the variable formatted properly to generate a positive match? "*$::item*" seems so convoluted.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Tue Apr 26, 2011 2:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-04-26T14:40:49-04:00</updated>

		<published>2011-04-26T14:40:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96777#p96777</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96777#p96777"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96777#p96777"><![CDATA[
The first part looks ok.<br><br>As for the second part, your if-conditional is not proper; you can't have the "then" keyword in it's current position. The proper syntax is as follows:<div class="codebox"><p>Code: </p><pre><code>if {test} then {true-code} else {false-code}#To ease readability, newlines may be added like this:if {test} then {  true-code} else {  false-code}#Further, the "then" and "else" keywords are optional:if {test} {  true-code} {  false-code}#Finally, we could also leave out the false-code part if it's not needed:if {test} {  true-code}</code></pre></div>In the above code, "test" would be a test that returns true or false;<br>true-code is a block of tcl-code that is to be evaluated if the test returns true;<br>false-code is a block of tcl-code that is to be evaluated if the test returns false<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 26, 2011 2:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-26T14:33:34-04:00</updated>

		<published>2011-04-26T14:33:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96776#p96776</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96776#p96776"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96776#p96776"><![CDATA[
Ok. Here is what I have for both of my binds and procs. They're also both present in the same script. I'm not sure if that is going to cause a problem, in itself.<br><br>I apologize for the lack of formatting. My editor doesn't appreciate TCL.<br><div class="codebox"><p>Code: </p><pre><code>foreach item $triggerwords { bind pubm - "% *${item}*" pubm:randaction}proc pubm:randaction {nick host hand channel text} {putserv "PRIVMSG $channel ":\001ACTION $randline \001"}</code></pre></div>I omitted the lines that generate the $randline variable, for the sake of space.<br><br>Here is the ctcp bind:<br><div class="codebox"><p>Code: </p><pre><code>bind ctcp - "ACTION" action_randactionproc action_randaction {nick host hand dest keyword text} {if {[string index $dest 0] !="#"} {return 0} then { if {[string match -nocase -- "*$::item*" $text]} {  putserv "PRIVMSG $channel :\001ACTION $randline \001"  } }}</code></pre></div>Same deal here. The code for $randline does exist in the script. It's just missing here for the sake of space.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Tue Apr 26, 2011 2:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-04-26T14:21:08-04:00</updated>

		<published>2011-04-26T14:21:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96775#p96775</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96775#p96775"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96775#p96775"><![CDATA[
You could use $item to replace the ocean part of the mask (assuming that the variable exists in the given context).<br>The mask has to match against "#channel text spoken", so at a minimum you'd have to use "% *${item}*" or "*${item}*" (the latter would also match if the "trigger-word" is present in the channel name, which is why I recommend the first one).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 26, 2011 2:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-26T13:47:42-04:00</updated>

		<published>2011-04-26T13:47:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96772#p96772</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96772#p96772"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96772#p96772"><![CDATA[
Instead of using "*ocean*" since I stored the trigger words in $item, can I use that variable in the statement? Like below:<br><div class="codebox"><p>Code: </p><pre><code>bind pubm - $item pubm::randaction</code></pre></div>Or will that rip a whole in the universe?<br><br>I can see that getting this script to do what I want is going to be a lot more effort than I'd planned for.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Tue Apr 26, 2011 1:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-04-26T13:43:25-04:00</updated>

		<published>2011-04-26T13:43:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96771#p96771</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96771#p96771"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96771#p96771"><![CDATA[
For actions, you have to remember that they're simple CTCP-action commands. As such, you'll need to use the CTCP binding for those. However, reading the docs, you'll see that the ctcp-bindings only matches against the ctcp-command, not it's arguments.. thus you'll have to bind against ACTION, and do some additional checking within your code:<div class="codebox"><p>Code: </p><pre><code>...if {[string match -nocase -- "*ocean*" $the_text]} {  #Stuff to do if the action contains "ocean"</code></pre></div>Next, for normal messages, this is a little simpler; you'll have to replace the pub binding with a pubm (matching binding), along with a proper mask. Something like this should do the trick:<div class="codebox"><p>Code: </p><pre><code>bind pubm - "% *ocean*" pubm::randaction</code></pre></div>Needless to say, since we're changing the bindings, make sure you adapt your proc(s) to the new bindings. Also, don't use the same proc for multiple bindings of different kinds unless you are absolutely sure on what you're doing - generally, it's a better idea to create a separate proc for each kind of binding.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 26, 2011 1:43 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-26T13:21:30-04:00</updated>

		<published>2011-04-26T13:21:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96769#p96769</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96769#p96769"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96769#p96769"><![CDATA[
The script is working the way it should, but I have one more issue.<br><br>The proc only responds when the trigger word is the first word in the post. So, it won't kick off if the word is in an "action" post or if the word is within a statement.<br><br>i.e. If the trigger word is "ocean" and a user says:<br><br>"The ocean is blue today!"<br>or<br>/me looks at the ocean.<br><br>Neither of the above posts will trigger the proc.<br><br>Any suggestions?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Tue Apr 26, 2011 1:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-20T14:20:18-04:00</updated>

		<published>2011-04-20T14:20:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96703#p96703</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96703#p96703"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96703#p96703"><![CDATA[
Awesome.<br><br>I will put this together and give it a try when I get back home.<br><br>Thanks for the help!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Wed Apr 20, 2011 2:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-04-20T14:05:56-04:00</updated>

		<published>2011-04-20T14:05:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96702#p96702</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96702#p96702"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96702#p96702"><![CDATA[
Technically, triggerwords has a single value. It's just a long string with multiple newlines within it. To some extent, it could also be considered a handcrafted list (though this requires caution).<br><br>The "pub" binds, or triggers, are matched against individual lines of text from a channel (and only against the first word of the line), so having multiple words or lines will not provide a suitable mask. However, there is nothing preventing you from creating multiple triggers; one for each word of your crafted list.<br>Something like this should take care of that:<div class="codebox"><p>Code: </p><pre><code>...foreach item $triggerwords {  bind pub - $item randaction}...</code></pre></div>Now, for your proc "randaction";<br>You try to read the local variable randline, though there exists no such local variable within the proc. I would guess you intended to access the globalspace variable randline instead:<div class="codebox"><p>Code: </p><pre><code>proc randaction {nick host handle channel text} {  puthelp "PRIVMSG $channel :\001ACTION $::randline\001"}</code></pre></div>This uses the :: fully qualified namespace path to access the variable. You could also use the "global" command to link the localspace variable to the globalspace of the same name though.<br>I also fixed the order of your parameters to match what the trigger will provide when calling the proc.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Apr 20, 2011 2:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Seka]]></name></author>
		<updated>2011-04-21T14:33:52-04:00</updated>

		<published>2011-04-20T13:21:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96701#p96701</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96701#p96701"/>
		<title type="html"><![CDATA[[SOLVED] How to Call a Single Variable with Multiple Values]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96701#p96701"><![CDATA[
So, here's my question. If I have a single variable set with multiple values, as sampled below:<br><div class="codebox"><p>Code: </p><pre><code>set triggerwords {messmessymopshiftcratelampoceansea}</code></pre></div>And I want to use the variable $triggerwords to kick off a proc. Will the following code work properly if only one of the values is use in a line of text?<br><div class="codebox"><p>Code: </p><pre><code>bind pub - $triggerwords randactionproc randaction {nick uhost channel hand text} {putserv "PRIVMSG $channel :\001ACTION $randline."}</code></pre></div>$randline is a variable from another piece of code. I think you can see what I'm going for, with the format.<br><br>I keep re-reading it and thinking there's something wrong or missing.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11646">Seka</a> — Wed Apr 20, 2011 1:21 pm</p><hr />
]]></content>
	</entry>
	</feed>
