This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Support & discussion of released scripts, and announcements of new releases.
4everlearning
Voice
Posts: 8 Joined: Wed Jan 26, 2011 4:32 am
Post
by 4everlearning » Tue May 22, 2012 1:40 am
can someone please help me get this working. I have loaded this script as youtube.tcl but for some reason the bot won't respond to anything in channel for this script. I tried doing .chanset #chan +youtube without any luck. here is the script
Code: Select all
# YouTube (Eggdrop/Tcl), Version 1.3
#
# (c) creative (QuakeNet - #computerbase), 15. Feb. 2012
#
# This program is free software: you can redistribute it and / or modify it under the
# terms of the GNU General Public License, see http://www.gnu.org/licenses/gpl.html.
#
# Example:
# <bo2000> like her new video https://www.youtu.be/kfVsfOSbJY0
# <eggbert> [Y] Rebecca Black - Friday - Official Music Video, 17.09.2011 (O 1.8)
#
# Notice:
# !youtube (on|off) enables or disables script for active channel (flags "mno" only)
setudef flag youtube
bind pubm - *youtu.be/* YouTube
bind pubm - *youtube.com/watch*v=* YouTube
bind pub mno|mno !youtube YouTube-Settings
proc YouTube {nick host hand chan text} {
if {[channel get $chan youtube]} {
set y_api "http://gdata.youtube.com/feeds/api/videos/"
set y_odf "%d.%m.%Y"
if {[catch {package require http 2.5}]} {
putlog "YouTube: package http 2.5 or above required"
} else {
if {[regexp -nocase {(^|[ ]{1})(https{0,1}:\/\/(www\.){0,1}|www\.)(youtu\.be\/|youtube\.com\/watch[^ ]{1,}v=)([A-Za-z0-9_-]{11})} $text - - - - - y_vid]} {
if {[catch {set y_con [::http::geturl $y_api$y_vid -headers [list {GData-Version} {2}] -timeout 5000]}]} {
putlog "YouTube: connection error (e. g. host not found / reachable)"
} elseif {[::http::status $y_con] == "ok"} {
set y_data [::http::data $y_con]
catch {::http::cleanup $y_con}
} else {
putlog "YouTube: connection error (e. g. time out / no data received)"
catch {::http::cleanup $y_con}
}
}
}
}
if {[info exists y_data]} {
if {[regexp -nocase {<title>(.{1,})<\/title>} $y_data - y_data_t]} {
set y_data_t [string map -nocase [list {"} {"} {&} {&} {<} {<} {>} {>}] $y_data_t]
regsub -all -nocase {[ ]{1,}} $y_data_t { } y_data_t
} else {
putlog "YouTube: parsing error (<title>, $y_api$y_vid)"
}
if {[regexp -nocase {<published>([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.000Z)<\/published>} $y_data - y_data_p]} {
set y_data_p [clock scan $y_data_p -format %Y-%m-%dT%H:%M:%S.000Z]
set y_data_p [clock format $y_data_p -format $y_odf]
} else {
putlog "YouTube: parsing error (<published>, $y_api$y_vid)"
}
if {[regexp -nocase {<gd:rating average='([0-9]{1}\.[0-9]{1,})'} $y_data - y_data_r]} {
set y_data_r [format %.1f $y_data_r]
set y_data_r "([encoding convertto utf-8 \u00D8] $y_data_r)"
} else {
set y_data_r "([encoding convertto utf-8 \u00D8] NR)"
}
if {[info exists y_data_t] && [info exists y_data_p] && [info exists y_data_r]} {
putserv "privmsg $chan :\002\0031,0You\0030,4Tube\003\002 $y_data_t, $y_data_p $y_data_r"
}
}
}
proc YouTube-Settings {nick host hand chan text} {
if {![channel get $chan youtube] && $text == "on"} {
catch {channel set $chan +youtube}
putserv "notice $nick :YouTube: enabled for $chan"
putlog "YouTube: script enabled (by $nick for $chan)"
} elseif {[channel get $chan youtube] && $text == "off"} {
catch {channel set $chan -youtube}
putserv "notice $nick :YouTube: disabled for $chan"
putlog "YouTube: script disabled (by $nick for $chan)"
} else {
putserv "notice $nick :YouTube: !youtube (on|off) enables or disables script for active channel"
}
}
putlog "YouTube 1.3 loaded"
Thank you for any and all help
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue May 22, 2012 11:28 am
Code: Select all
proc YouTube-Settings {nick host hand chan text} {
set status [channel get $chan youtube]
set mode [string tolower [lindex [split $text] 0]]
switch -- $mode {
"on" {
if {!$status} {
channel set $chan +youtube
puthelp "NOTICE $nick :YouTube: enabled for $chan"
putlog "YouTube script enabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already enabled for $chan"
}
}
"off" {
if {$status} {
channel set $chan -youtube
puthelp "NOTICE $nick :YouTube disabled for $chan"
putlog "YouTube script disabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already disabled for $chan"
}
}
default {
puthelp "notice $nick :YouTube: !youtube (on|off) enables or disables script for active channel"
}
}
}
Once the game is over, the king and the pawn go back in the same box.
4everlearning
Voice
Posts: 8 Joined: Wed Jan 26, 2011 4:32 am
Post
by 4everlearning » Tue May 22, 2012 9:08 pm
Thank you caesar,
I will reload with this tonight.
4everlearning
Voice
Posts: 8 Joined: Wed Jan 26, 2011 4:32 am
Post
by 4everlearning » Fri May 25, 2012 1:39 am
I tested what caesar posted without luck
Here is the code I have now:
Code: Select all
# YouTube (Eggdrop/Tcl), Version 1.3
#
# (c) creative (QuakeNet - #computerbase), 15. Feb. 2012
#
# This program is free software: you can redistribute it and / or modify it under the
# terms of the GNU General Public License, see http://www.gnu.org/licenses/gpl.html.
#
# Example:
# <bo2000> like her new video https://www.youtu.be/kfVsfOSbJY0
# <eggbert> [Y] Rebecca Black - Friday - Official Music Video, 17.09.2011 (O 1.8)
#
# Notice:
# !youtube (on|off) enables or disables script for active channel (flags "mno" only)
setudef flag youtube
bind pubm - *youtu.be/* YouTube
bind pubm - *youtube.com/watch*v=* YouTube
bind pub mno|mno !youtube YouTube-Settings
proc YouTube {nick host hand chan text} {
if {[channel get $chan youtube]} {
set y_api "http://gdata.youtube.com/feeds/api/videos/"
set y_odf "%d.%m.%Y"
if {[catch {package require http 2.5}]} {
putlog "YouTube: package http 2.5 or above required"
} else {
if {[regexp -nocase {(^|[ ]{1})(https{0,1}:\/\/(www\.){0,1}|www\.)(youtu\.be\/|youtube\.com\/watch[^ ]{1,}v=)([A-Za-z0-9_-]{11})} $text - - - - - y_vid]} {
if {[catch {set y_con [::http::geturl $y_api$y_vid -headers [list {GData-Version} {2}] -timeout 5000]}]} {
putlog "YouTube: connection error (e. g. host not found / reachable)"
} elseif {[::http::status $y_con] == "ok"} {
set y_data [::http::data $y_con]
catch {::http::cleanup $y_con}
} else {
putlog "YouTube: connection error (e. g. time out / no data received)"
catch {::http::cleanup $y_con}
}
}
}
}
if {[info exists y_data]} {
if {[regexp -nocase {<title>(.{1,})<\/title>} $y_data - y_data_t]} {
set y_data_t [string map -nocase [list {"} {"} {&} {&} {<} {<} {>} {>}] $y_data_t]
regsub -all -nocase {[ ]{1,}} $y_data_t { } y_data_t
} else {
putlog "YouTube: parsing error (<title>, $y_api$y_vid)"
}
if {[regexp -nocase {<published>([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.000Z)<\/published>} $y_data - y_data_p]} {
set y_data_p [clock scan $y_data_p -format %Y-%m-%dT%H:%M:%S.000Z]
set y_data_p [clock format $y_data_p -format $y_odf]
} else {
putlog "YouTube: parsing error (<published>, $y_api$y_vid)"
}
if {[regexp -nocase {<gd:rating average='([0-9]{1}\.[0-9]{1,})'} $y_data - y_data_r]} {
set y_data_r [format %.1f $y_data_r]
set y_data_r "([encoding convertto utf-8 \u00D8] $y_data_r)"
} else {
set y_data_r "([encoding convertto utf-8 \u00D8] NR)"
}
if {[info exists y_data_t] && [info exists y_data_p] && [info exists y_data_r]} {
putserv "privmsg $chan :\002\0031,0You\0030,4Tube\003\002 $y_data_t, $y_data_p $y_data_r"
}
}
}
proc YouTube-Settings {nick host hand chan text} {
set status [channel get $chan youtube]
set mode [string tolower [lindex [split $text] 0]]
switch -- $mode {
"on" {
if {!$status} {
channel set $chan +youtube
puthelp "NOTICE $nick :YouTube: enabled for $chan"
putlog "YouTube script enabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already enabled for $chan"
}
}
"off" {
if {$status} {
channel set $chan -youtube
puthelp "NOTICE $nick :YouTube disabled for $chan"
putlog "YouTube script disabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already disabled for $chan"
}
}
default {
puthelp "notice $nick :YouTube: !youtube (on|off) enables or disables script for active channel"
}
}
}
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Fri May 25, 2012 1:59 am
<caesar> !youtube
-bot- YouTube: !youtube (on|off) enables or disables script for active channel
<caesar> !youtube off
-bot- YouTube is already disabled for #chan
<caesar> !youtube on
-bot- YouTube: enabled for #chan
<caesar> !youtube on
-bot- YouTube is already enabled for #chan
<caesar> !youtube off
-bot- YouTube disabled for #chan
so, what's not working properly in the code I gave you?
Once the game is over, the king and the pawn go back in the same box.
4everlearning
Voice
Posts: 8 Joined: Wed Jan 26, 2011 4:32 am
Post
by 4everlearning » Thu Jun 07, 2012 4:47 am
I got no response from the bot at all. It's Ok tho, I gave up on this script and found another one that I liked enough to edit it to my total likings.
Thanks for your help.
sputnik
Voice
Posts: 20 Joined: Wed Feb 23, 2011 1:16 pm
Post
by sputnik » Thu May 09, 2013 8:13 am
The script works fine, but it doesn't show utf-8 chars in the title. Any ideas?
SinSoLe
Voice
Posts: 3 Joined: Sat Jun 25, 2011 1:36 pm
Post
by SinSoLe » Thu May 30, 2013 10:11 am
sputnik wrote: The script works fine, but it doesn't show utf-8 chars in the title. Any ideas?
You can use
encode function to convertfrom/convertto. Try changing this line
Code: Select all
putserv "privmsg $chan :\002\0031,0You\0030,4Tube\003\002 $y_data_t, $y_data_p $y_data_r"
to this
Code: Select all
putserv "privmsg $chan :\002\0031,0You\0030,4Tube\003\002 [encoding convertfrom utf-8 $y_data_t], $y_data_p $y_data_r"
sputnik
Voice
Posts: 20 Joined: Wed Feb 23, 2011 1:16 pm
Post
by sputnik » Thu May 30, 2013 10:32 am
That worked. Thanks!
sputnik
Voice
Posts: 20 Joined: Wed Feb 23, 2011 1:16 pm
Post
by sputnik » Thu May 30, 2013 10:37 am
One more question (also stupid one): how do i bind it to ctcp action?
doesn't do a thing...
sputnik
Voice
Posts: 20 Joined: Wed Feb 23, 2011 1:16 pm
Post
by sputnik » Thu May 30, 2013 12:08 pm
Nope, i believe i need bind #15.
willyw
Revered One
Posts: 1203 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Thu May 30, 2013 12:11 pm
Give us an example of what you want the bot to react to.
willyw
Revered One
Posts: 1203 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Thu May 30, 2013 12:51 pm
Not sure why it didn't work for you. It seems to work for me.
Play with this:
Code: Select all
bind ctcp - "ACTION" pub_test_me
proc pub_test_me {nick uhost handle dest keyword text} {
if {$text == "http://youtubevideourl"} {
putserv "privmsg $dest :Whatever you want to happen goes here"
# and here
}
}
It reacts to:
/me
http://youtubevideourl
p.s.
If we need to continue much more, can you start another thread on just this?