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

	<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>2006-12-04T12:19:28-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-12-04T12:19:28-04:00</updated>

		<published>2006-12-04T12:19:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68700#p68700</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68700#p68700"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68700#p68700"><![CDATA[
Space got lost in your link, but adding %20 instead of the space worked just well.<br>The problem with your regular expression is that ^ is interpreted as a special atom, namely beginning of line. You'll have to escape it within your regular expression to be able to match a ^-char explicitly.<br><br>The following should work well for you (using rosc's suggestions on implementation of the http-package):<div class="codebox"><p>Code: </p><pre><code>proc anagram:public {nick uhost hand chan text} { set anagram [string map {" " "%20"} $text] set url "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram" catch {set page [::http::geturl $url -timeout 10000]} error if {[string match -nocase "*couldn't open socket*" $error]} {  puthelp "PRIVMSG $nick :Error: couldn't connect..Try again later"  return } if { [::http::status $page] == "timeout" } {  puthelp "PRIVMSG $nick :Error: Connection timed out."  return } set content [::http::data $page] ::http::cleanup $page  if {[regexp {(.+?) \^ (.+?)&lt;br&gt;} $content match name answer]} {  puthelp "PRIVMSG $chan :\00302Anagram lookup for: \00307$text"  puthelp "PRIVMSG $chan :\00307$name \00302- \00307$answer" } {  puthelp "PRIVMSG $chan :Your query for $text did not yield any results" }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Dec 04, 2006 12:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Red_Rooste5]]></name></author>
		<updated>2006-12-04T11:47:17-04:00</updated>

		<published>2006-12-04T11:47:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68699#p68699</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68699#p68699"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68699#p68699"><![CDATA[
<a href="http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=a" class="postlink">http://www.slushpuppy.silverinterlocuti ... anagrams=a</a> bas<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8308">Red_Rooste5</a> — Mon Dec 04, 2006 11:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-12-03T14:49:14-04:00</updated>

		<published>2006-12-03T14:49:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68680#p68680</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68680#p68680"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68680#p68680"><![CDATA[
As long as the webpage returns "No match for anagram&lt;br&gt;&lt;br&gt;", none of the scripts posted here will "work". And frankly, I'm not sure how to mine the data out of that (what would be "name" and what would be "answer" in that text), I'd rather guess this output would be some error message that the anagram was not found.<br><br>So, once again, please provide us with a valid result from that php-script so we know what to look for...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Dec 03, 2006 2:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Red_Rooste5]]></name></author>
		<updated>2006-12-03T13:26:34-04:00</updated>

		<published>2006-12-03T13:26:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68679#p68679</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68679#p68679"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68679#p68679"><![CDATA[
Well, I made EXACTLY your script, though I get the msg:<br><blockquote class="uncited"><div>can't read "content": no such variable<br>    while executing<br>"proc anagram:public {nick uhost hand chan text} {<br>if {![llength [set anagram [lindex [split $text] 0]]]} {<br>putquick "PRIVMSG $chan :Specify an anagram..."<br>    (file "scripts/anagram.tcl" line 7)<br>    invoked from within<br>"source scripts/anagram.tcl"<br>    (file "eggdrop.conf" line 1343)</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8308">Red_Rooste5</a> — Sun Dec 03, 2006 1:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2006-12-03T09:37:32-04:00</updated>

		<published>2006-12-03T09:37:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68676#p68676</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68676#p68676"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68676#p68676"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>if {[catch {package require http} err]} returnproc anagram:public {nick uhost hand chan text} {  if {![llength [set anagram [lindex [split $text] 0]]]} {    putserv "PRIVMSG $chan :Specify an anagram"    return  }  set token [::http::geturl "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram"]  set content [::http::data $token]  ::http::cleanup $content  regsub -all {&lt;[^&gt;]+&gt;|&lt;} $content { } content  if {[regexp {(.+?) ^ (.+?)&lt;br&gt;} $content match name answer]} {    putquick "PRIVMSG $chan :\00302Anagram lookup for: \00307$text"    putquick "PRIVMSG $chan :\00307$name \00302- \00307$answer"  }  # debug?  # putserv "PRIVMSG $chan :$content"}</code></pre></div>Tell me something valid to test in case it dosen't seem to be working.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sun Dec 03, 2006 9:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-12-03T08:01:52-04:00</updated>

		<published>2006-12-03T08:01:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68672#p68672</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68672#p68672"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68672#p68672"><![CDATA[
It's because the webpage returns "No match for anagram&lt;br&gt;&lt;br&gt;". If you would post the output of a proper query, we could verify if your regexp matches the format used or not, and possibly fix it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Dec 03, 2006 8:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Red_Rooste5]]></name></author>
		<updated>2006-12-03T07:36:59-04:00</updated>

		<published>2006-12-03T07:36:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68670#p68670</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68670#p68670"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68670#p68670"><![CDATA[
<blockquote class="uncited"><div>I'd suggest you check wether your regexp matched the epxression before trying to use the submatch variables.<br><br>In this case, as the webpage returns "No match for anagram&lt;br&gt;&lt;br&gt;", it won't match that regexp (and thus no submatches either).<br>Try something like this:<div class="codebox"><p>Code: </p><pre><code>proc anagram:public {nick uhost hand chan text} { set anagram [string map {" " "%20"} $text] set site "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram" set token [::http::geturl $site] set content [::http::data $token] if {[regexp {(.+?) ^ (.+?)&lt;br&gt;} $content match name answer]} {  putquick "PRIVMSG $chan :\00302Anagram lookup for: \00307$text"  putquick "PRIVMSG $chan :\00307$name \00302- \00307$answer" }}</code></pre></div></div></blockquote>I used that but now it msgs nothing and I'm not getting any error msgs.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8308">Red_Rooste5</a> — Sun Dec 03, 2006 7:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-12-03T06:36:23-04:00</updated>

		<published>2006-12-03T06:36:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68663#p68663</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68663#p68663"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68663#p68663"><![CDATA[
I keep forgetting about the [info exists] cmd, I need to get in the habit of using it (too many years of shell-scripting..)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sun Dec 03, 2006 6:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-12-03T04:54:33-04:00</updated>

		<published>2006-12-03T04:54:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68658#p68658</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68658#p68658"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68658#p68658"><![CDATA[
Actually, you'd have better options if you do <strong class="text-strong">not</strong> init those vars to "".<br>Namley "info exists &lt;variable&gt;"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Dec 03, 2006 4:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-12-02T18:38:12-04:00</updated>

		<published>2006-12-02T18:38:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68637#p68637</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68637#p68637"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68637#p68637"><![CDATA[
I'd also init the vars with set name ""  and set answer ""  then you can test if $name != "" and so forth.<br><br>And generally, you want to test that the geturl operation was successful:<div class="codebox"><p>Code: </p><pre><code>#antiwordwrap#################################################################################        set url "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram"        catch {set page [::http::geturl $url -timeout 10000]} error        if {[string match -nocase "*couldn't open socket*" $error]} {                puthelp "PRIVMSG $nick :Error: couldn't connect..Try again later"                return        }        if { [::http::status $page] == "timeout" } {                puthelp "PRIVMSG $nick :Error: Connection timed out."                return        }        set html [::http::data $page]        ::http::cleanup $page</code></pre></div>That's the basic gist of it. Don't forget to call ::http::cleanup when you're done pulling data in, so you're not leaving open sockets behind.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sat Dec 02, 2006 6:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-12-02T16:53:24-04:00</updated>

		<published>2006-12-02T16:53:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68636#p68636</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68636#p68636"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68636#p68636"><![CDATA[
I'd suggest you check wether your regexp matched the epxression before trying to use the submatch variables.<br><br>In this case, as the webpage returns "No match for anagram&lt;br&gt;&lt;br&gt;", it won't match that regexp (and thus no submatches either).<br>Try something like this:<div class="codebox"><p>Code: </p><pre><code>proc anagram:public {nick uhost hand chan text} { set anagram [string map {" " "%20"} $text] set site "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram" set token [::http::geturl $site] set content [::http::data $token] if {[regexp {(.+?) ^ (.+?)&lt;br&gt;} $content match name answer]} {  putquick "PRIVMSG $chan :\00302Anagram lookup for: \00307$text"  putquick "PRIVMSG $chan :\00307$name \00302- \00307$answer" }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Dec 02, 2006 4:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Red_Rooste5]]></name></author>
		<updated>2006-12-02T16:13:26-04:00</updated>

		<published>2006-12-02T16:13:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=68635#p68635</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=68635#p68635"/>
		<title type="html"><![CDATA[regexp help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=68635#p68635"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc anagram:public {nick uhost hand chan text} {set anagram [string map {" " "%20"} $text]set site "http://www.slushpuppy.silverinterlocution.org/anagrams.php?anagrams=$anagram"set token [::http::geturl $site]set content [::http::data $token]regexp {(.+?) ^ (.+?)&lt;br&gt;} $content match name answerputquick "PRIVMSG $chan :\00302Anagram lookup for: \00307$text"putquick "PRIVMSG $chan :\00307$name \00302- \00307$answer"}</code></pre></div>Well, I get the answer: <br>[21:12] Tcl error [anagram:public]: can't read "name": no such variable<br><br>If you want to look at the parser source, use a bas instead of $anagram<br><br>I really need help with this script.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8308">Red_Rooste5</a> — Sat Dec 02, 2006 4:13 pm</p><hr />
]]></content>
	</entry>
	</feed>
