Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################
- # Youtube TCL v1.1 by munZe ##
- # Requed TCL 8.5 or remove $uploaded #
- ######################################
- bind pubm - *youtu.be/* YouTube
- bind pubm - *youtube.com/watch*v=* YouTube
- proc YouTube {nick host hand chan text} {
- if {[checkUserAbuse $nick $chan] == "1"} {
- set ytid [regexp -all -inline -nocase {([A-Za-z0-9_-]{11})} $text]; set ytid [lindex $ytid 0]
- set url "http://gdata.youtube.com/feeds/api/videos/$ytid?v=2&alt=jsonc&prettyprint=true"
- set token [ ::http::geturl $url ]; set page [ ::http::data $token ]
- ::http::cleanup $token
- set duration [regexp -all -inline {"duration": (.*?),} $page]; set duration [lindex $duration 1]; set duration [clock format $duration -gmt 1 -format %H:%M:%S]
- set title [regexp -all -inline {"title": "(.*?)",} $page]; set title [lindex $title 1]
- set likes [regexp -all -inline {"likeCount": "(.*?)",} $page]; set likes [lindex $likes 1]
- set views [regexp -all -inline {"viewCount": (.*?),} $page]; set views [lindex $views 1]
- set uploader [regexp -all -inline {"uploader": "(.*?)",} $page]; set uploader [lindex $uploader 1]
- set uploaded [regexp -all -inline {"uploaded": "(.*?)",} $page]; set uploaded [lindex $uploaded 1]; set uploaded [clock scan $uploaded -format {%Y-%m-%dT%H:%M:%S.000Z}]; set uploaded [clock format $uploaded -format {%d.%m.%Y}]
- putserv "PRIVMSG $chan :Youtube - Title: \002$title\002 - Duration: \002$duration\002 - Likes: \002$likes\002 - Views: \002$views\002 - Uploaded by: \002$uploader\002 - Uploaded: \002$uploaded\002"
- }
- }
- ######################
- # Flood protect #
- ######################
- set floodTime 10
- set floodmsg 3
- set banDuration 10
- proc initCmdUser {host time} {
- global usersbanovani
- set usersbanovani($host) [list 0 [list $time]]
- return
- }
- proc checkUserAbuse {nick chan} {
- set host [getchanhost $nick $chan]
- global usersbanovani banDuration floodTime floodmsg
- set time [unixtime]
- if {![array exists usersbanovani]} {
- initCmdUser $host $time
- return 1
- }
- set seenNick 0
- foreach user [array names usersbanovani] {
- if {$user == $host} {set seenNick 1; break}
- }
- if {$seenNick == 0} {
- initCmdUser $host $time
- return 1
- }
- if {[lindex $usersbanovani($host) 0] != 0} {
- if {[lindex $usersbanovani($host) 0] <= $time} {
- array set usersbanovani [list $host [list 0 [list $time]]]
- return 1
- }
- return 0
- }
- set messages {}
- foreach m [lindex $usersbanovani($host) 1] {
- if {[expr $time-$m] <= $floodTime} {
- lappend messages $m
- }
- }
- lappend messages $time
- array set usersbanovani [list $host [list 0 $messages]]
- if {[llength $messages] > $floodmsg} {
- set host [getchanhost $nick]
- array set usersbanovani [list $host [list [expr $time+($banDuration*60)] {}]]
- return 0
- }
- return 1
- }
- ######################
- putlog "Loaded YouTube TCL v1.1 by munZe"
Advertisement
Add Comment
Please, Sign In to add comment