mirror of https://github.com/fluffle/goirc
Handle http://youtube.com without www and allow links that don't start lines
This commit is contained in:
parent
93e335a606
commit
35351e93bb
|
@ -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]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue