Revert "Bot now responds to "cringe twitter posts" regardless of whether they contain a video"

This reverts commit 264cdee4d1.
This commit is contained in:
Logan G 2023-03-15 21:34:03 -06:00
parent 264cdee4d1
commit 6568813ce3
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -33,6 +33,8 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
log.Printf("Message %s has URLs!", message.ID)
respond := false
for _, url := range urls {
if output, _ := regexp.MatchString("(http.*twitter.com/.*/status)|(http.*t.co/.*)", url); output {
log.Println("Cringe twitter post detected.")
@ -52,7 +54,13 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
if err != nil {
log.Println(err)
// 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)
}
continue
} else {
choice, err := getLargestFormat(result, 8*1024*1024)
@ -77,6 +85,8 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
log.Println(err)
}
}
respond = true
} else if output, _ := regexp.MatchString("(http.*youtube.com/watch.*?v=.*)|(http.*youtube.com/shorts/.*)|(http.*youtu.be/.*)", url); output {
log.Println("YouTube detected.")
@ -128,6 +138,8 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
log.Println(err)
}
}
respond = true
} else if output, _ := regexp.MatchString("(http.*instagram\\.com/p/.*)|(http.*instagram\\.com/tv/.*)|(http.*instagram\\.com/reel/.*)", url); output {
log.Println("Instagram detected.")
@ -171,6 +183,8 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
downloadResult.Close()
}
respond = true
} else if output, _ := regexp.MatchString("(http.*tiktok\\.com/\\@.*)", url); output {
log.Println("TikTok detected.")
@ -203,6 +217,8 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
log.Println(err)
}
}
respond = true
} else if output, _ := regexp.MatchString("(http.*reddit\\.com/r/\\.*)", url); output {
log.Println("Reddit detected.")
@ -213,7 +229,12 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
if err != nil {
// If it's complaining due to a lack of videos, don't care.
log.Println(err)
if noVideo, _ := regexp.MatchString(".*No media found.*", err.Error()); noVideo {
respond = true
} else {
log.Println(err)
}
continue
} else {
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
@ -239,14 +260,18 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
}
}
*/
respond = true
}
}
if result, err := session.ChannelMessageSendComplex(message.ChannelID, &response); err != nil {
log.Println(result)
log.Println(err)
} else {
log.Printf("Successfully responded to %s", message.ID)
if respond {
if result, err := session.ChannelMessageSendComplex(message.ChannelID, &response); err != nil {
log.Println(result)
log.Println(err)
} else {
log.Printf("Successfully responded to %s", message.ID)
}
}
}
}