# # ourTube.tcl -- # This file search the web target and show relevant information about. # Is posible define a YouTube account and the bot will log in. Useful # when the link are for adult people i.e. It will show the first link # that finds in a whole phrase. # # Copyright (c) 2007-2009 Eggdrop Spain 12-april-2009 # HackeMate (Sentencia) Sentencia@eggdrop.es # # This program is free software; you can redistribute it and/or # modify it _only for your own use_ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Please, use the email to contact with the author for let him know about all # what you could do. Everyone wants develop his software as well. # # Thank you for feed my empiric life. # # If you like, you can contact with the author to suggest him features. By the # way, do not ask him to make Login, he is working on that. # This is what you need to get this script work: # Type in partyline: .chanset #channel +ourtube setudef flag ourtube global ourtube tcl_platform # (1) Enable or (0) disable colors set ourtube(colors) 1 # Flood Protection: after show a link, will ignore all links few seconds # This means 1 link per 10 seconds. set ourtube(delay) 15 # What language you can receive the youTube data? (if works heh) set ourtube(lang) en # This is the final output message what you will read in your channel. # You can configure all fields that your eggdrop will show. # will return the title of the video # <author> It was the author himself who had uploaded the video # <views> How much views the video has # <rating> His rating # <description> Information by author - This may be disabled because it can # contain spam # <comment> Will show the last comment if exists - Same as description, take care # with spam. # #### set ourtube(output) "\00305<title> \003- \00310<description>\00314. Добавил: \00303<author>, \00314Просмотров: \00303<views>, \00314Комментов: \00303<comments>\00314. Последний комментарий: \00303<comment>" # This is not required to edit, or yes. set ourtube(author) "HackeMate" set ourtube(contact) "HackeMate <Sentencia@eggdrop.es>" set ourtube(fileName) [file tail [info script]] set ourtube(projectName) "ourTube" set ourtube(version) "1.0" set ourtube(package.http) [package require http] set ourtube(protection) "" if {$tcl_platform(os) eq "Linux"} { set platfrm "X11" } else { set platfrm $tcl_platform(os) } http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $ourtube(lang); rv:1.9.0.3) ourTube 1.0" -accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" bind pubm - * otPub proc otPub {nick uhost hand chan text} { if {![channel get $chan ourtube]} { return } global ourtube regsub -all -- {\017|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $text "" arg set webTarget [lsearch -inline [split $arg] *http://*youtube*watch*] if {$webTarget ne ""} { if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} { otLog "Unsupported URL: $webTarget" return } if {[info exists ourtube(lasttime,$chan)] && [expr $ourtube(lasttime,$chan) + $ourtube(delay)] > [clock seconds]} { putlog "ourTube- Wait [expr $ourtube(delay) - [expr [clock seconds] - $ourtube(lasttime,$chan)]] seconds before next request." return } otLog "Getting $webTarget ... from $nick on $chan" set data [otGet $webTarget] if {!$ourtube(colors)} { regsub -all -- {\017|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $data "" data } if {[string length $data] == 0} { set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again." } otLog "$data" putserv "PRIVMSG $chan :[string range [join $data] 0 399]" putserv "PRIVMSG $chan :\00303[string range [join $data] 400 end]" set ourtube(lasttime,$chan) [clock seconds] } } proc otGet {web} { global ourtube set token [http::geturl $web -timeout 4000] upvar #0 $token state set data [string map {""\;" "\"" "&\;quot\;" "\"" "&" "&" "'" "'"} $state(body)] http::cleanup $token set title ""; set author ""; set description ""; set views ""; set comments "" regexp {'COMMENTS_COUNT': (.*?),} $data "" commentstotal regexp {<title>.*?- (.*?)} $data "" title regexp {(.*?)} $data "" author regexp {} $data "" description regexp {(.*?).*} $data "" views regexp {