Bot now responds to "cringe twitter posts" regardless of whether they contain a video
This commit is contained in:
parent
fe946398d7
commit
264cdee4d1
1 changed files with 7 additions and 32 deletions
|
@ -33,8 +33,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
|
|
||||||
log.Printf("Message %s has URLs!", message.ID)
|
log.Printf("Message %s has URLs!", message.ID)
|
||||||
|
|
||||||
respond := false
|
|
||||||
|
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
if output, _ := regexp.MatchString("(http.*twitter.com/.*/status)|(http.*t.co/.*)", url); output {
|
if output, _ := regexp.MatchString("(http.*twitter.com/.*/status)|(http.*t.co/.*)", url); output {
|
||||||
log.Println("Cringe twitter post detected.")
|
log.Println("Cringe twitter post detected.")
|
||||||
|
@ -54,13 +52,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
|
|
||||||
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If it's complaining due to a lack of videos, don't care.
|
|
||||||
if noVideo, _ := regexp.MatchString(".*There's no video in this tweet.*", err.Error()); noVideo {
|
|
||||||
respond = true
|
|
||||||
} else {
|
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
choice, err := getLargestFormat(result, 8*1024*1024)
|
choice, err := getLargestFormat(result, 8*1024*1024)
|
||||||
|
@ -85,8 +77,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
respond = true
|
|
||||||
} else if output, _ := regexp.MatchString("(http.*youtube.com/watch.*?v=.*)|(http.*youtube.com/shorts/.*)|(http.*youtu.be/.*)", url); output {
|
} else if output, _ := regexp.MatchString("(http.*youtube.com/watch.*?v=.*)|(http.*youtube.com/shorts/.*)|(http.*youtu.be/.*)", url); output {
|
||||||
log.Println("YouTube detected.")
|
log.Println("YouTube detected.")
|
||||||
|
|
||||||
|
@ -138,8 +128,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
respond = true
|
|
||||||
} else if output, _ := regexp.MatchString("(http.*instagram\\.com/p/.*)|(http.*instagram\\.com/tv/.*)|(http.*instagram\\.com/reel/.*)", url); output {
|
} else if output, _ := regexp.MatchString("(http.*instagram\\.com/p/.*)|(http.*instagram\\.com/tv/.*)|(http.*instagram\\.com/reel/.*)", url); output {
|
||||||
log.Println("Instagram detected.")
|
log.Println("Instagram detected.")
|
||||||
|
|
||||||
|
@ -183,8 +171,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
|
|
||||||
downloadResult.Close()
|
downloadResult.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
respond = true
|
|
||||||
} else if output, _ := regexp.MatchString("(http.*tiktok\\.com/\\@.*)", url); output {
|
} else if output, _ := regexp.MatchString("(http.*tiktok\\.com/\\@.*)", url); output {
|
||||||
log.Println("TikTok detected.")
|
log.Println("TikTok detected.")
|
||||||
|
|
||||||
|
@ -217,8 +203,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
respond = true
|
|
||||||
} else if output, _ := regexp.MatchString("(http.*reddit\\.com/r/\\.*)", url); output {
|
} else if output, _ := regexp.MatchString("(http.*reddit\\.com/r/\\.*)", url); output {
|
||||||
log.Println("Reddit detected.")
|
log.Println("Reddit detected.")
|
||||||
|
|
||||||
|
@ -229,12 +213,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If it's complaining due to a lack of videos, don't care.
|
// If it's complaining due to a lack of videos, don't care.
|
||||||
if noVideo, _ := regexp.MatchString(".*No media found.*", err.Error()); noVideo {
|
|
||||||
respond = true
|
|
||||||
} else {
|
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
|
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
|
||||||
|
@ -260,12 +239,9 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
respond = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if respond {
|
|
||||||
if result, err := session.ChannelMessageSendComplex(message.ChannelID, &response); err != nil {
|
if result, err := session.ChannelMessageSendComplex(message.ChannelID, &response); err != nil {
|
||||||
log.Println(result)
|
log.Println(result)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -274,4 +250,3 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue