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

	<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>2013-03-10T12:58:44-04:00</updated>

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

		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T12:58:44-04:00</updated>

		<published>2013-03-10T12:58:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101208#p101208</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101208#p101208"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101208#p101208"><![CDATA[
Update:<br><br>Final code and works like a charm. Now i got some reading to do to understand the difference.<br><div class="codebox"><p>Code: </p><pre><code>proc proc_msgm {nick host handle text} {    global memo    set items [split $text]    set temp [list "verify" "ident" "addhost" "pass" "info" "voice" "halfop" "invite" "key" "op" "status" "notes"]    set danger [list "die" "jump" "reset"]    set chan "#prototype"    if {[matchattr $nick n]} {        return 1    }    foreach pattern $temp {        if {[lsearch -nocase $items $pattern] &gt;= 0} {            puthelp "PRIVMSG $chan :$nick has just messaged me, using the \002$pattern\002 command."            return 1        }    }    foreach pattern $danger {        if {[lsearch -nocase $items $pattern] &gt;= 0} {            putserv "PRIVMSG $chan :\002WARNING!\002 User \002$nick\002 has just attempted to use the \002$pattern\002 command."            putserv "PRIVMSG $chan :Full output is: \002$text\002."            putserv "PRIVMSG $memo :send lokii Master, a user \002$nick\002 has just attempted to issue the \002$pattern\002 command on me via /msg. His full output was: \002$text\002."            return 1        }    }    puthelp "PRIVMSG $chan :$nick messaged me saying: '$text'"    return 1}</code></pre></div>Many thanks for your help <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=10917">LoKii</a> — Sun Mar 10, 2013 12:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T12:12:34-04:00</updated>

		<published>2013-03-10T12:12:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101207#p101207</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101207#p101207"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101207#p101207"><![CDATA[
<blockquote class="uncited"><div>Sorry, made a minor mistake... <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"><br>Should've tested for greater or equal to zero, not less than zero...<br><br>I'll update my previous post in a sec or two...</div></blockquote>Yup, now it works like a charm. I will try to understand the difference between yours and mine, to make sure that in the future, my code will be more effective.<br><br>Will convert my version into yours, and show it.<br><br>Many thanks for your help everyone <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=10917">LoKii</a> — Sun Mar 10, 2013 12:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-10T12:05:48-04:00</updated>

		<published>2013-03-10T12:05:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101206#p101206</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101206#p101206"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101206#p101206"><![CDATA[
Sorry, made a minor mistake... <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"><br>Should've tested for greater or equal to zero, not less than zero...<br><br>I'll update my previous post in a sec or two...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Mar 10, 2013 12:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T12:07:49-04:00</updated>

		<published>2013-03-10T12:03:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101205#p101205</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101205#p101205"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101205#p101205"><![CDATA[
Your solution didnt quite work for me.<br><br>No matter what i write in a /msg bot , the result is ALWAYS:<br><blockquote class="uncited"><div>LoKii has just messaged me, using the verify command.</div></blockquote>I dont really understand why yet, but I'm sure I will figure it out once i understand what you meant with using the foreach-loop once.<br><br>In the mean time, my code is:<br><div class="codebox"><p>Code: </p><pre><code>proc proc_msgm {nick uhost hand arg} {    global memo    set chan "#prototype"    set line [string trim $arg]    set items [split [string tolower $line]]    set temp {        "verify"        "ident"        "addhost"        "pass"        "info"        "voice"        "halfop"        "invite"        "key"        "op"        "status"        "notes"    }    set danger {        "die"        "jump"        "reset"    }    if {[matchattr $nick n]} {        return 1    }    foreach pattern $temp {        foreach match [lsearch -all -inline $items $pattern] {            putserv "PRIVMSG $chan :$nick has just messaged me, using the \002$pattern\002 command."            return 1                 }    }    foreach pattern $danger {        foreach match [lsearch -all -inline $items $pattern] {            putserv "PRIVMSG $chan :\002WARNING!\002 User \002$nick\002 has just attempted to use the \002$pattern\002 command."            putserv "PRIVMSG $chan :Full output is: \002$arg\002."            putserv "PRIVMSG $memo :send lokii Master, a user \002$nick\002 has just attempted to issue the \002$pattern\002 command on me via /msg. His full output was: \002$arg\002."            return 1        }    }    puthelp "PRIVMSG $chan :$nick messaged me saying: '$line'"    return 1}</code></pre></div>Which works great, except I'm sure that your method is less resource-hungry.<br><br>BTW, i got my code based on a code that <strong class="text-strong">you</strong> have written in: <a href="http://forum.egghelp.org/viewtopic.php?t=18997&amp;highlight=lists" class="postlink">http://forum.egghelp.org/viewtopic.php? ... ight=lists</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10917">LoKii</a> — Sun Mar 10, 2013 12:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T11:42:58-04:00</updated>

		<published>2013-03-10T11:42:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101204#p101204</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101204#p101204"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101204#p101204"><![CDATA[
@ nml375<br><br><br>Simple, I dont know either. Im a total n00b trying to get my scripts  to work the way I imagine.<br><br>I will try out your suggestion and let you know in a bit  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"> <br><br>If I showed you my main script which is around 3000 lines by now, you would prolly shoot me for raping TCL.<br><br>Cheers for your help. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10917">LoKii</a> — Sun Mar 10, 2013 11:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-10T12:06:45-04:00</updated>

		<published>2013-03-10T11:35:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101203#p101203</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101203#p101203"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101203#p101203"><![CDATA[
LoKii,<br>I'm not sure why you're using a second foreach-loop with lsearch in inline mode as the source. Just test the result from lsearch; if it's 0 or greater, there was a match, while -1 indicates there was no match.<br>My recommendation is something along these lines:<br><div class="codebox"><p>Code: </p><pre><code>proc proc_msgm {nick host handle text} {  set items [split $text]  set temp [list "verify" "ident" "addhost" "pass"]  set chan "#prototype"  foreach pattern $temp {    if {[lsearch -nocase $items $pattern] &gt;= 0} {      puthelp "PRIVMSG $chan :$nick has just messaged me, using the \002$pattern\002 command."      return 1    }  }  puthelp "PRIVMSG $chan :$nick messaged me saying: '$text'"  return 1}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Mar 10, 2013 11:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T11:01:48-04:00</updated>

		<published>2013-03-10T11:01:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101202#p101202</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101202#p101202"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101202#p101202"><![CDATA[
update:<br><br>I got it to work this way:<br><div class="codebox"><p>Code: </p><pre><code>proc proc_msgm {nick uhost hand arg} {    set chan "#prototype"    set line [string trim $arg]    set items [split [string tolower $line]]    set temp {        "verify"        "ident"        "addhost"        "pass"    }    foreach pattern $temp {        foreach match [lsearch -all -inline $items $pattern] {            putserv "PRIVMSG $chan :$nick has just messaged me, using the \002$pattern\002 command."           return 1                 }    }    puthelp "PRIVMSG $chan :$nick messaged me saying: '$line'"    return 1}</code></pre></div>Using the lsearch. <br><br>Cheers everyone and sorry again for hijacking this thread  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10917">LoKii</a> — Sun Mar 10, 2013 11:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T10:37:59-04:00</updated>

		<published>2013-03-10T10:37:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101199#p101199</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101199#p101199"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101199#p101199"><![CDATA[
Yes, i also discovered that lsearch is the way to go.<br><br>What i am trying to accomplish is,  i took a script called: <strong class="text-strong">forward.tcl </strong>written by <strong class="text-strong">r0gUe</strong>.<br><br>His script basicly just relays any msg to the bot to a specified channel.<br><br>What i want to do, is to edit it, so that certain messages are not relayed with the same output, due to security, such as pass/ident/auth/addhost etc....<br><br>What i have so far is:<br><div class="codebox"><p>Code: </p><pre><code>bind msgm - "*" proc_msgmproc proc_msgm {nick uhost hand arg} {    set chan "#prototype"    set line [string trim $arg]    set temp {        "verify"        "ident"        "addhost"        "pass"    }    foreach a $temp [split $arg]{        if {[string match -nocase $a $arg]} {            putserv "PRIVMSG $chan :$nick has used the $a command"                    }    }    puthelp "PRIVMSG $chan :$nick messaged me saying: '$line'"    return 1}</code></pre></div>So I am not too worried about large rooms and such, since its only in the rare cases that someone pms the bot. I just want to make sure that no passwords though go through, which is why i am attempting to change the output in the 'if' statement on certain words.<br><br>Cheers<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10917">LoKii</a> — Sun Mar 10, 2013 10:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2013-03-10T10:21:16-04:00</updated>

		<published>2013-03-10T10:21:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101198#p101198</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101198#p101198"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101198#p101198"><![CDATA[
I am trying more and more to use lsearch (i never used that in the past) so i have to try use it now in the present <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> yet as i used foreach alot it would be a little weird for me at start <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> but ill try use it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Sun Mar 10, 2013 10:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Papillon]]></name></author>
		<updated>2013-03-10T10:11:52-04:00</updated>

		<published>2013-03-10T10:11:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101197#p101197</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101197#p101197"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101197#p101197"><![CDATA[
Madalin:<br>Instead of using a foreach loop which is slow, why not just use the standard tcl-command <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/lsearch.htm" class="postlink"><strong class="text-strong">lsearch</strong></a>?<br><br>LoKii:<br>In that case I would use a loop on each word said by the user and do a <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/lsearch.htm" class="postlink"><strong class="text-strong">lsearch</strong></a> on the list. Word of warning though, if your channel is very crowded and people are chatty this will be very time-consuming on the bot. I have not been writing tcl-code for years and have forgotten alot, so might be a much more effecient way of doing it if you search around <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=852">Papillon</a> — Sun Mar 10, 2013 10:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LoKii]]></name></author>
		<updated>2013-03-10T08:49:01-04:00</updated>

		<published>2013-03-10T08:49:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101196#p101196</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101196#p101196"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101196#p101196"><![CDATA[
forgive me for hijacking this thread, a small question regarding it.<br><br>This code is based on the first word said in the sentence, but if i want to capture any word from the sentence which is in the temp(words) list, how would i go about doing it, if the word is <strong class="text-strong">NOT</strong> the first word?<br><br>Cheers.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10917">LoKii</a> — Sun Mar 10, 2013 8:49 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2013-02-28T16:22:17-04:00</updated>

		<published>2013-02-28T16:22:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101145#p101145</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101145#p101145"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101145#p101145"><![CDATA[
No problem, glad i could help<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Thu Feb 28, 2013 4:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[alkoleht]]></name></author>
		<updated>2013-02-28T16:19:37-04:00</updated>

		<published>2013-02-28T16:19:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101144#p101144</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101144#p101144"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101144#p101144"><![CDATA[
awesome, it works. thank you.<br>i was going completely different approach to this problem before but this solution works just perfect. Much appreciated<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11706">alkoleht</a> — Thu Feb 28, 2013 4:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2013-02-28T16:09:50-04:00</updated>

		<published>2013-02-28T16:09:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101142#p101142</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101142#p101142"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101142#p101142"><![CDATA[
Try this code and tell if this is what you wanted<br><div class="codebox"><p>Code: </p><pre><code>bind MSGM - * check:msgmset temp(chan) "#channel"set temp(words) {"word1""word2"}proc check:msgm {nick uhost hand arg} {global tempforeach a $temp(words) {if {[string match -nocase $a [lindex [split $arg] 0]]} {putserv "PRIVMSG $temp(chan) :$nick said \002[lindex [split $arg] 0]\002"return} else {putserv "PRIVMSG $temp(chan) :$nick said: $arg"return}}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Thu Feb 28, 2013 4:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[alkoleht]]></name></author>
		<updated>2013-02-28T15:18:19-04:00</updated>

		<published>2013-02-28T15:18:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101141#p101141</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101141#p101141"/>
		<title type="html"><![CDATA[need help with lists]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101141#p101141"><![CDATA[
Hi. I am pretty noob when it comes to TCL but i am trying to learn.<br>I am trying to create a script that will take user msg to bot, does some matching and relays it to chan.<br>here is how it looks in reality:<br><br>1. let's say i have a list of words:<br><div class="codebox"><p>Code: </p><pre><code>set word {flowerbeehouse}</code></pre></div>2. user MSG-s to bot, ether just one word or more text, doesnt matter.<br>example: <div class="codebox"><p>Code: </p><pre><code>/msg bot house is tv show</code></pre></div>3. script then takes the <strong class="text-strong">first</strong> word of imput and matches that to $word . also no matter if the input is CAPS or lower case or MiXeD<br>4. if first word matches then say in chan:<div class="codebox"><p>Code: </p><pre><code>&lt;bot&gt; $nick sayd $word</code></pre></div>if the first word does not match $word list then it will say the full imput into the chan.<br><br>so example:<div class="codebox"><p>Code: </p><pre><code>&lt;user&gt;/msg &lt;bot&gt; house is tv show&lt;bot&gt; &lt;user&gt; says word [b]house[/b]&lt;user&gt;/msg &lt;bot&gt; there is a house in tv right now&lt;bot&gt; &lt;user&gt; says: there is a house in tv right now</code></pre></div>i know it may sound strange but that is something i want to create.<br>any help with this would be appreciated<br>Thank you<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11706">alkoleht</a> — Thu Feb 28, 2013 3:18 pm</p><hr />
]]></content>
	</entry>
	</feed>
