Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##############
- # Zurl #
- ##############
- ############## Zurl.tcl is based on two grabbers urls titles scripts:
- ############## -The first one is a classic grabber who gets all (or most) of urls.
- ############## (http://forum.eggdrop.fr/Titre-des-urls-diffusees-t-1331.html)
- ############## - The second one is a youtube grabber.
- ############## (http://forum.eggdrop.fr/youtube-tiltle-t-1393.html)
- ##############
- ############## So, the youtube and the classic grabber titles on
- ############## one script was the point. I hope it'll be usefull.
- ##############
- ############## Easy to use; you only need to:
- ############## - add the Zurl.tcl file in ../scripts/
- ############## - add the line "source scripts/zurl.tcl" in eggdrop.conf
- ############## - and enjoy.
- ##############
- ############## JazZ (jazz@epiknet.org)
- ##############
- # Script #
- ##############
- set Zurlversion "1.0"
- ############## Binds/Packages
- package require http
- package require uri
- package require tls
- tls::init -tls1 true -ssl2 false -ssl3 false
- http::register https 443 tls::socket
- bind PUBM - * check_url
- ############## Classic Proc
- proc check_url {nick uhost handle chan text} {
- if {![string match "*?://*?" $text]} {
- set text "http://$text"
- }
- if {[regexp -- {([a-z0-9\-]+\://[a-z0-9\-]+\.[a-z0-9\-\.]+(?:/|(?:/[a-zA-Z0-9!#\$%&'\*\+,\-\.:;=\?@\[\]_~]+)*))} $text match url]} {
- if {[string match -nocase "*?/watch?v=*?" $url] || [string match -nocase "*?://youtu.be*?" $url]} {
- return [get_ytube $chan $url]
- } else {
- set url [string tolower $url]
- set url [string map -nocase { "&" "&" } $url]
- set token [geturl $url]
- set html_data [::http::data $token]
- ::http::cleanup $token
- regexp -all -nocase -- "<title>(.*)</title>" $html_data match title
- putserv "PRIVMSG $chan .: \002URL\002 :. '[html_entities_decode $title]'"
- }
- }
- return 0
- }
- proc geturl {url args} {
- array set URI [::uri::split $url];
- while {1} {
- set token [eval [list http::geturl $url] $args]
- if {![string match {30[1237]} [::http::ncode $token]]} {return $token}
- array set meta [set ${token}(meta)]
- if {![info exist meta(Location)]} {
- return $token
- }
- array set uri [::uri::split $meta(Location)]
- unset meta
- if {$uri(host) == ""} { set uri(host) $URI(host) }
- set url [eval ::uri::join [array get uri]]
- }
- }
- putlog "Zurl-$Zurlversion.tcl loaded"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement