Handle http://youtube.com without www and allow links that don't start lines

This commit is contained in:
Raymond Lu 2010-10-27 21:02:28 -04:00
parent 93e335a606
commit 35351e93bb
1 changed files with 2 additions and 7 deletions

View File

@ -50,13 +50,8 @@ func handlePrivmsg(conn *irc.Conn, line *irc.Line) {
target := line.Args[0] target := line.Args[0]
if isChannel(target) { if isChannel(target) {
// message to a channel // message to a channel
var video string if start := strings.Index(line.Text, "youtube.com/watch?v="); start > -1 {
if strings.HasPrefix(line.Text, "http://www.youtube.com/watch?v=") { video := line.Text[start+20:]
video = line.Text[31:]
} else if strings.HasPrefix(line.Text, "http://www.youtube.com/watch?v=") {
video = line.Text[27:]
}
if video != "" {
if end := strings.IndexAny(video, " &#"); end > -1 { if end := strings.IndexAny(video, " &#"); end > -1 {
video = video[0:end] video = video[0:end]
} }