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.

YouTube script little help

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
FmX
Voice
Posts: 32
Joined: Wed Dec 06, 2006 12:42 pm

YouTube script little help

Post by FmX »

Hello. Can someone help me with this script:

Code: Select all

bind pub - "+youtube" youtube_url
proc youtube_url {nick uhost handle channel text arg} {
  set url_regex {(https?://www\.youtube\.com/watch\?v=[a-zA-Z0-9_-]+)}
  if {[regexp $url_regex $arg url]} {
    set modified_url [string map {"youtube.com/watch?v=" "youtubepp.com/watch?v="} $url]
    putnow "PRIVMSG $channel :@ $nick, here is the youtube change link: $modified_url"
  }
}
Purpose of the script is that if someone post youtube url in channel, bot reply with same url but added pp
after youtube.
But when loaded it, nothing happens when someone post youtube url. Please some help
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

try this:

Code: Select all


bind pubm - "*http*youtube*" youtube_url
 
proc youtube_url {nick uhost hand chan text} {
  set url_regex {(?:http(?:s|).{3}|)(?:www.|)(?:youtube.com\/watch\?.*v=|youtu.be\/)([\w-]{11})}
  if {[regexp $url_regex $text url]} {
    set modified_url [string map {"youtube.com/watch?v=" "youtubepp.com/watch?v="} $url]
    putnow "PRIVMSG $chan :@ $nick, here is the youtube change link: $modified_url"
  }
}

User avatar
FmX
Voice
Posts: 32
Joined: Wed Dec 06, 2006 12:42 pm

Post by FmX »

Work like a charm :wink: Thanks simo
Post Reply