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

	<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>2024-01-30T03:54:33-04:00</updated>

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

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2024-01-30T03:54:33-04:00</updated>

		<published>2024-01-30T03:54:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=112387#p112387</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=112387#p112387"/>
		<title type="html"><![CDATA[Re: tcl script to call data from an api]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=112387#p112387"><![CDATA[
Here is a small script:<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark-reasonable.min.css"> <strong>script</strong>  <strong>script</strong> <div class="codebox"><pre><code class="language-tcl">namespace eval radu {   variable raduurl "http://radu.ovh:8080/crypto"   variable raduchan "#test"      package require http   package require json      proc feedget {url} {      set tok [::http::geturl $::radu::raduurl -timeout 1000]      upvar 0 $tok state      if {$state(status) ne "ok"} {         putlog "HTTP Error : $state(url) made $state(status) error"         return "error"      }      set datas [::http::data $tok]      ::http::cleanup $tok      return [json2dict $datas]   }      proc newsb {min hour day month dow} {      set datas [::radu::feedget $::radu::raduurl]      if {$datas eq "error" } {         return      }      set datas [::json::json2dict $datas]      foreach e $datas {         putserv "PRIVMSG $::radu::raduurl :[dict get $e titlu] ([dict get $e sursa])      }         }   bind cron - "*/15 * * * *" ::radu::newsb}</code></pre></div> <strong>script</strong> It can be improved to use asynchronous callback so the script won't be blocked if the timeout delay is increased<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Tue Jan 30, 2024 3:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[sirducu]]></name></author>
		<updated>2024-01-29T12:32:24-04:00</updated>

		<published>2024-01-29T12:32:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=112382#p112382</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=112382#p112382"/>
		<title type="html"><![CDATA[Re: tcl script to call data from an api]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=112382#p112382"><![CDATA[
I kind of made it working <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"> <br>with a little help from this forum and the internet.. but maybe you guys can help me make it a little better ..<br>here is the code .<br><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark-reasonable.min.css"> <strong>script</strong>  <strong>script</strong> <div class="codebox"><pre><code class="language-tcl">package require httppackage require jsonputlog "newsbot loaded"proc getinfo { url } {for { set i 1 } { $i &lt;= 5 } { incr i } {        set rawpage [http::data [http::geturl "$url" -timeout 50000]]        if {[string length rawpage] &gt; 0} { break }        }        if {[string length $rawpage] == 0} { error "newsapi returned ZERO no data :( or we couldnt connect properly" }set json [json::many-json2dict $rawpage]return $json}proc newsb {min hour day month dow} {    set chan "channel"    set url "YOURURL"    set news [getinfo $url]    for {set i 0} {$i &lt; 1} {incr i} {        set title [encoding convertfrom [lindex $news 0 $i 1]]    set sursa [lindex $news 0 $i 3]    set link [lindex $news 0 $i 5]        if { $i == 0 } {            set output "Top stories : $title - $sursa (@$link)"        } else {           set output "$title - $sursa (@ $link)"    }        puthelp "PRIVMSG $chan :$output"}}bind cron -"*/15 * * * *" newsb</code></pre></div> <strong>script</strong> <em class="text-italics"><span style="color:#40FF00">Moderation: added [ tcl ] and [ /tcl ] tags</span></em><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12975">sirducu</a> — Mon Jan 29, 2024 12:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2024-01-29T10:30:50-04:00</updated>

		<published>2024-01-29T10:30:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=112380#p112380</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=112380#p112380"/>
		<title type="html"><![CDATA[Re: tcl script to call data from an api]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=112380#p112380"><![CDATA[
Ok, let me formulate it in another way: I need the url of the API, and I've to know which datas you want to retrieve from the json.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Mon Jan 29, 2024 10:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2024-01-29T07:01:34-04:00</updated>

		<published>2024-01-29T07:01:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=112378#p112378</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=112378#p112378"/>
		<title type="html"><![CDATA[Re: tcl script to call data from an api]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=112378#p112378"><![CDATA[
Without knowing which API you want to use and wich datas in it, we can't help you.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Mon Jan 29, 2024 7:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[sirducu]]></name></author>
		<updated>2024-01-29T06:06:35-04:00</updated>

		<published>2024-01-29T06:06:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=112377#p112377</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=112377#p112377"/>
		<title type="html"><![CDATA[tcl script to call data from an api]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=112377#p112377"><![CDATA[
Hello guys,<br><br>I am looking for a script that can call data from an API, and post to a certain channel, I don't need it to post on multiple channels.<br>The API doesn't need a key to call from it.<br>If anyone can help, that would be awesome, if not, please point me to a place where I can learn TCL scripting.<br><br>Thank you!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12975">sirducu</a> — Mon Jan 29, 2024 6:06 am</p><hr />
]]></content>
	</entry>
	</feed>
