08/10/2021, 16:01
(This post was last modified: 08/10/2021, 16:05 by ComputerTech.)
Hey everyone, this is a beta release of CTweather, i'll be working on another release later today. :) (btw: not sure if i should be speaking English or French, Mods please let me know, hehe)
tcl
namespace eval CTweather {
## Trigger
variable trig "!w
## Flag
variable flag "of|of
###
variable api "8c2a600d5d63d7fb13432fd58dcc419
variable type "imperia
package require js
package require tl
package require htt
bind PUB $flag $trig [namespace current]::mainpr
proc mainproc {nick host hand chan text}
variable api ;variable typ
::http::register https 443 [list ::tls::socket
variable url "https://nominatim.openstreetmap.org/search/
variable params [::http::formatQuery q $text format jsonv2
putlog "$url?$params
variable data [http::data [http::geturl "$url?$params" -timeout 10000]
variable data2 [json::json2dict $data
variable name [dict get [lindex $data2 0] "display_name"
variable lati [dict get [lindex $data2 0] "lat"
variable long [dict get [lindex $data2 0] "lon"
variable url2 "https://api.openweathermap.org/data/2.5/weather
variable params2 [::http::formatQuery q [lindex [split $text] 0] lat $lati lon $long appid $api
putlog "$url2?$params2
variable bata [http::data [http::geturl "$url2?$params2" -timeout 10000]
variable zata [::json::json2dict $bata
variable temp [dict get [dict get $zata "main"] "temp"
variable speed [dict get [dict get $zata "wind"] "speed"
variable degre [dict get [dict get $zata "wind"] "deg"
variable humid [dict get [dict get $zata "main"] "humidity"
variable cover [dict get [dict get $zata "clouds"] "all"
variable desc [dict get [lindex [dict get $zata weather] 0] "description"
variable sign [encoding convertfrom "utf-8" "?"
switch -exact $type
"metric" {variable type2 "${sign}F"
"imperial" {variable type2 "${sign}C"
putserv "PRIVMSG $chan :\[\00309Weather\003\] Location: $name || Longitutde: $long || Latitude: $lati || Temperature:: ${temp}$type2 || Humidity: ${humid}%
putserv "PRIVMSG $chan :Wind:: ${speed}MPH Degree: $degre || Description:: $desc || Clouds: ${cover}%
}}""}}}{]]]]]]]]]"]"]]]]]"]"]e {ocpsonl"b"##"s.".iption:: $desc || Clouds: ${cover}%"
}
}