egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Weather Script - .py to .tcl conversion?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
neocharles
Voice


Joined: 23 Apr 2013
Posts: 34

PostPosted: Sun Jul 28, 2013 2:50 pm    Post subject: Weather Script - .py to .tcl conversion? Reply with quote

I am looking at this script here... https://code.google.com/p/crappy-irc-bot/source/browse/plugin/[censored].py?r=569da12c7660ee19e543e310dd10323ab1791b42

Any shot that can easily be moved over (and work) as a tcl file for an eggdrop?
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Tue Nov 05, 2013 11:58 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
neocharles
Voice


Joined: 23 Apr 2013
Posts: 34

PostPosted: Tue Apr 01, 2014 11:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber