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

	<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>2019-03-02T10:27:42-04:00</updated>

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

		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-03-02T10:27:42-04:00</updated>

		<published>2019-03-02T10:27:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107499#p107499</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107499#p107499"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107499#p107499"><![CDATA[
hm still gettin same error<br><br>Tcl error [::newsFetch::fetch]: wrong # args: should be "tls::socket ?options? host port"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Sat Mar 02, 2019 10:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-03-02T04:10:57-04:00</updated>

		<published>2019-03-02T04:10:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107498#p107498</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107498#p107498"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107498#p107498"><![CDATA[
Right, replace the <em class="text-italics">news</em> in the namespace line with something else, let's say <em class="text-italics">newsFetch</em> and restart the bot. Issue the !new cnbc (or whatever) and see what happens.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Mar 02, 2019 4:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-03-01T15:17:07-04:00</updated>

		<published>2019-03-01T15:17:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107497#p107497</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107497#p107497"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107497#p107497"><![CDATA[
this is what i got so far and i didnt get the log in PL<br><div class="codebox"><p>Code: </p><pre><code>namespace eval news {    set news(key) "my key"    set news(url) "https://newsapi.org/v2/top-headlines?sources=%source&amp;sortBy=latest&amp;apiKey=%key"    set news(sources) "https://newsapi.org/v2/sources?apiKey=%key"    set news(timeout) 5000    package require http    package require json    package require tls    proc tls:socket args {       set opts [lrange $args 0 end-2]       set host [lindex $args end-1]       set port [lindex $args end]       ::tls::socket -servername $host {*}$opts $host $port        putlog "tls:correct socket was called!"    }    bind pub * !news [namespace current]::fetch    proc fetch {nick uhost hand chan text} {       variable news       if {[scan $text {%s} source] != 1} {          puthelp "PRIVMSG $chan :Usage: !news &lt;source&gt; | Pick one from https://newsapi.org/sources"          return       }       ::http::register https 443 [namespace current]::tls:socket       set url [string map [list "%source" "$source" "%key" "$news(key)"] $news(url)]       set token [::http::geturl $url -timeout $news(timeout)]       set data [::http::data $token]       set json [::json::json2dict $data]       ::http::cleanup $token       ::http::unregister https       if {[dict get $json status] eq "ok"} {          set i 0          foreach item [dict get $json articles] {             if {[incr i] &gt; 3} break             dict with item {                puthelp "PRIVMSG $chan :Title: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"             }          }       } else {          puthelp "PRIVMSG $chan :The specified source is invalid, pick one from https://newsapi.org/sources"          # To see exact error message uncomment next line          #puthelp "PRIVMSG $chan :Error: [dict get $json message]"       }    } } </code></pre></div>still gettin :  Tcl error [::news::fetch]: wrong # args: should be "tls::socket ?options? host port"<br><br>and i got like max 5 tcls loaded wich none use tls and in conf neither<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Fri Mar 01, 2019 3:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-03-01T15:12:27-04:00</updated>

		<published>2019-03-01T15:12:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107496#p107496</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107496#p107496"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107496#p107496"><![CDATA[
Yeah, I messed with that. I added a command then changed my mind and forgot to fix it. Removing the extra ] behind -1 should do the trick. Edited and fixed the code above.<br><br>The <em class="text-italics">tls:socket</em> that I got in this code accepts any or no arguments. ANd since you get that error means you got the same code in some other place. To see if it's really the case then add a:<div class="codebox"><p>Code: </p><pre><code>putlog "correct tls::socket was called!"</code></pre></div>at the end of the <em class="text-italics">tls:socket</em> function and see if you see that message in the party-line.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Mar 01, 2019 3:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-03-01T10:04:03-04:00</updated>

		<published>2019-03-01T10:04:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107495#p107495</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107495#p107495"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107495#p107495"><![CDATA[
tested  it and got this error : <blockquote class="uncited"><div>14:58:12 &lt;TCL-Tester&gt; [14:56:42] Tcl error [::news::fetch]: invalid character "]"<br>14:58:12 &lt;TCL-Tester&gt; in expression "...text {%s} source] != 1]"</div></blockquote>after i changed it to     <blockquote class="uncited"><div>  if {[scan $text {%s} source] != 1} { </div></blockquote>it still returned me the old error of <br><blockquote class="uncited"><div>&lt;TCL-Tester&gt; [14:59:00] Tcl error [::news::fetch]: wrong # args: should be "tls::socket ?options? host port" </div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Fri Mar 01, 2019 10:04 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-03-01T15:08:20-04:00</updated>

		<published>2019-02-28T11:51:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107487#p107487</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107487#p107487"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107487#p107487"><![CDATA[
I haven't tested this on a bot cos at the time cos didn't have time for it, and since I had some spare time decided to have a look on this as well.<br><br>The problem is in this line:<div class="codebox"><p>Code: </p><pre><code>puthelp "PRIVMSG $chan: Ttitle: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url" </code></pre></div>More specific with <em class="text-italics">$chan:</em> where there should have been a space between the two. As it is right now, if your channel name is #test for example it will try to send the messages to the #test: channel. Notice the : behind the name. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><br><br>Transform the line into:<div class="codebox"><p>Code: </p><pre><code>puthelp "PRIVMSG $chan :Ttitle: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url" </code></pre></div>and will work as expected.<br><br>If the bot doesn't have some special privileges on your network it will flood itself off very easy since the code I mentioned above will just dump all the 10 articles from the page it grabs.<br><br>To display let's say fist 3 articles make the loop from:<div class="codebox"><p>Code: </p><pre><code>foreach item [dict get $json articles] {dict with item {puthelp "PRIVMSG $chan :Ttitle: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"}}</code></pre></div>to:<div class="codebox"><p>Code: </p><pre><code>set i 0foreach item [dict get $json articles] {if {[incr i] &gt; 3} breakdict with item {puthelp "PRIVMSG $chan :Title: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"}}</code></pre></div>for example.<br><br>Edit: Here's the updated code.<div class="codebox"><p>Code: </p><pre><code>namespace eval news {   set news(key) "your-key"   set news(url) "https://newsapi.org/v2/top-headlines?sources=%source&amp;sortBy=latest&amp;apiKey=%key"   set news(sources) "https://newsapi.org/v2/sources?apiKey=%key"   set news(timeout) 5000   package require http   package require json   package require tls   proc tls:socket args {      set opts [lrange $args 0 end-2]      set host [lindex $args end-1]      set port [lindex $args end]      ::tls::socket -servername $host {*}$opts $host $port   }   bind pub * !news [namespace current]::fetchproc fetch {nick uhost hand chan text} {variable newsif {[scan $text {%s} source] != 1} {puthelp "PRIVMSG $chan :Usage: !news &lt;source&gt; | Pick one from https://newsapi.org/sources"return}::http::register https 443 [namespace current]::tls:socketset url [string map [list "%source" "$source" "%key" "$news(key)"] $news(url)]set token [::http::geturl $url -timeout $news(timeout)]set data [::http::data $token]set json [::json::json2dict $data]::http::cleanup $token::http::unregister httpsif {[dict get $json status] eq "ok"} {set i 0foreach item [dict get $json articles] {if {[incr i] &gt; 3} breakdict with item {puthelp "PRIVMSG $chan :Title: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"}}} else {puthelp "PRIVMSG $chan :The specified source is invalid, pick one from https://newsapi.org/sources"# To see exact error message uncomment next line#puthelp "PRIVMSG $chan :Error: [dict get $json message]"}}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Feb 28, 2019 11:51 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dominatez]]></name></author>
		<updated>2019-02-23T15:56:23-04:00</updated>

		<published>2019-02-23T15:56:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107469#p107469</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107469#p107469"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107469#p107469"><![CDATA[
When i try !news it prompts for the <br><br>Usage: !news &lt;source&gt; | Pick one from <a href="https://newsapi.org/sources" class="postlink">https://newsapi.org/sources</a><br><br>When i try !news cnbc (Or any other) it does nothing. No errors. Just nothing.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12783">Dominatez</a> — Sat Feb 23, 2019 3:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-02-23T11:47:16-04:00</updated>

		<published>2019-02-23T11:47:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107468#p107468</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107468#p107468"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107468#p107468"><![CDATA[
sorry for the unclearity it is still giving same error<br><br>this is what i have in use<br><div class="codebox"><p>Code: </p><pre><code>namespace eval news {    set news(key) "MY-KEY"    set news(url) "https://newsapi.org/v2/top-headlines?sources=%source&amp;sortBy=latest&amp;apiKey=%key"    set news(timeout) 5000    package require http    package require json    package require tls    proc tls:socket args {       set opts [lrange $args 0 end-2]       set host [lindex $args end-1]       set port [lindex $args end]       ::tls::socket -servername $host {*}$opts $host $port    }    bind pub * !news [namespace current]::fetch    proc fetch {nick uhost hand chan text} {       variable news       if {[scan $text {%s} source] != 1} {          puthelp "PRIVMSG $chan :Usage: !news &lt;source&gt; | Pick one from https://newsapi.org/sources"          return       }       ::http::register https 443 [namespace current]::tls:socket       set url [string map [list "%source" "$source" "%key" "$news(key)"] $news(url)]       set token [::http::geturl $url -timeout $news(timeout)]       set data [::http::data $token]       set json [::json::json2dict $data]       ::http::cleanup $token       ::http::unregister https       if {[lsearch [dict get $json] "articles"] &gt; -1} {          foreach item [dict get $json articles] {             dict with item {                puthelp "PRIVMSG $chan: Ttitle: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"             }          }       } else {          puthelp "PRIVMSG $chan :The specified source is invalid, pick one from https://newsapi.org/sources"          # To see exact error message uncomment next line          #puthelp "PRIVMSG $chan: Error: [dict get $json message]"       }    } } </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Sat Feb 23, 2019 11:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-02-23T08:55:40-04:00</updated>

		<published>2019-02-23T08:55:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107467#p107467</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107467#p107467"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107467#p107467"><![CDATA[
Should I take it that was right and now it's working?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Feb 23, 2019 8:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-02-23T07:58:29-04:00</updated>

		<published>2019-02-23T07:58:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107466#p107466</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107466#p107466"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107466#p107466"><![CDATA[
hm ok yes i restarted not sure where i went wrong as i used it as is<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Sat Feb 23, 2019 7:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-02-23T04:12:21-04:00</updated>

		<published>2019-02-23T04:12:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107465#p107465</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107465#p107465"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107465#p107465"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>% package require http2.8.12% package require tls1.6.7% proc tls:socket args {        set opts [lrange $args 0 end-2]        set host [lindex $args end-1]        set port [lindex $args end]        ::tls::socket -servername $host {*}$opts $host $port}% ::http::register https 443 tls:socket443 tls:socket%</code></pre></div>It's still something on your side. Did you restart the bot after unloading scripts?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Feb 23, 2019 4:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-02-22T17:59:18-04:00</updated>

		<published>2019-02-22T17:59:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107464#p107464</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107464#p107464"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107464#p107464"><![CDATA[
i checked and unloaded all  scripts and checked entire conf and made sure <br>yet still same error<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Fri Feb 22, 2019 5:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-02-22T14:55:32-04:00</updated>

		<published>2019-02-22T14:55:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107460#p107460</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107460#p107460"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107460#p107460"><![CDATA[
By any chance you have the <em class="text-italics">tls:socket</em> defined in some other place? I'm asking cos the version in my code takes any or no arguments, yet the error "tls::socket ?options? host port" tells me that you do, so be sure you don't.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Feb 22, 2019 2:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2019-02-22T12:36:19-04:00</updated>

		<published>2019-02-22T12:36:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107458#p107458</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107458#p107458"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107458#p107458"><![CDATA[
hey there caesar i tried your version of the tcl and it returns this on !news abc-news<br><blockquote class="uncited"><div>Tcl error [::news::fetch]: wrong # args: should be "tls::socket ?options? host port"<br></div></blockquote><div class="codebox"><p>Code: </p><pre><code>namespace eval news {    set news(key) "MY-KEY"    set news(url) "https://newsapi.org/v2/top-headlines?sources=%source&amp;sortBy=latest&amp;apiKey=%key"    set news(timeout) 5000    package require http    package require json    package require tls    proc tls:socket args {       set opts [lrange $args 0 end-2]       set host [lindex $args end-1]       set port [lindex $args end]       ::tls::socket -servername $host {*}$opts $host $port    }    bind pub * !news [namespace current]::fetch    proc fetch {nick uhost hand chan text} {       variable news       if {[scan $text {%s} source] != 1} {          puthelp "PRIVMSG $chan :Usage: !news &lt;source&gt; | Pick one from https://newsapi.org/sources"          return       }       ::http::register https 443 [namespace current]::tls:socket       set url [string map [list "%source" "$source" "%key" "$news(key)"] $news(url)]       set token [::http::geturl $url -timeout $news(timeout)]       set data [::http::data $token]       set json [::json::json2dict $data]       ::http::cleanup $token       ::http::unregister https       if {[lsearch [dict get $json] "articles"] &gt; -1} {          foreach item [dict get $json articles] {             dict with item {                puthelp "PRIVMSG $chan: Ttitle: [encoding convertfrom $title] | desc: [encoding convertfrom $description] | url: $url"             }          }       } else {          puthelp "PRIVMSG $chan :The specified source is invalid, pick one from https://newsapi.org/sources"          # To see exact error message uncomment next line          #puthelp "PRIVMSG $chan: Error: [dict get $json message]"       }    } } </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Fri Feb 22, 2019 12:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2019-02-22T04:13:17-04:00</updated>

		<published>2019-02-22T04:13:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107457#p107457</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107457#p107457"/>
		<title type="html"><![CDATA[Not Working 100%]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107457#p107457"><![CDATA[
Missed an $ there. Find news(timeout) and make it $news(timeout) and should work.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Feb 22, 2019 4:13 am</p><hr />
]]></content>
	</entry>
	</feed>
