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.
The API doesn't need a key to call from it.
If anyone can help, that would be awesome, if not, please point me to a place where I can learn TCL scripting.
I kind of made it working
with a little help from this forum and the internet.. but maybe you guys can help me make it a little better ..
here is the code .
package require http
package require json
putlog "newsbot loaded"
proc getinfo { url } {
for { set i 1 } { $i <= 5 } { incr i } {
set rawpage [http::data [http::geturl "$url" -timeout 50000]]
if {[string length rawpage] > 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 < 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