| View previous topic :: View next topic |
| Author |
Message |
neocharles Voice
Joined: 23 Apr 2013 Posts: 34
|
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Tue Nov 05, 2013 11:58 am Post subject: |
|
|
| Code: | # e-mail: tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
###########################################################
bind pub - !fw fweather
package require tdom
package require http
proc fweather { nick uhost hand chan arg } {
set arg [string trim $arg]
if {$arg != ""} {
set f_url "http://thefuckingweather.com/?where=$arg"
regsub -all {\s} $f_url "+" f_url
set f_fake_ua "Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0"
set f_token [http::config -useragent $f_fake_ua]
if {[catch {set f_token [::http::geturl $f_url -timeout 10000]}]} {
putquick "PRIVMSG $chan :Error retrieving [censored] weather data!"
} else {
set f_data [[dom parse -html [http::data $f_token]] getElementsByTagName span]
foreach f_loc_temp $f_data {
set location_data [string trim [$f_loc_temp asText]]
if {$location_data != ""} {
if {[regexp {^([0-9]+)$} $location_data]} {
set location_data "${location_data}°"
}
putquick "PRIVMSG $chan :$location_data"
} else {
putquick "PRIVMSG $chan :location: $arg not found"
}
}
}
} else {
putquick "PRIVMSG $chan :use: !fw <location>"
}
}
putlog "fweather.tcl ver 0.1 by tomekk loaded" |
|
|
| Back to top |
|
 |
neocharles Voice
Joined: 23 Apr 2013 Posts: 34
|
Posted: Tue Apr 01, 2014 11:18 am Post subject: |
|
|
Thank you for doing this - Apparently I didn't have notifications turned on.
My problem now, however, is that it uses tdom. I used apt-get to install tdom and tdom-dev, but it still errors out when starting it.
| Code: | me@me:~/eggdrop/$ tclsh
% package require tdom
0.8.3
% exit |
So it looks like it's installed... however
| Code: | [11:18:14] Tcl error in file 'eggdrop.conf':
[11:18:14] can't find package tdom
while executing
"package require tdom"
(file "scripts/fweather.tcl" line 12)
invoked from within
"source scripts/fweather.tcl"
(file "eggdrop.conf" line 1405)
[11:18:14] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR) |
<edit>
Looks like I had to just move over some things... thanks speechless for assisting.
Now, it's just a matter of re-writing some of this script to parse the data correctly.... |
|
| Back to top |
|
 |
|