fixed crashes
This commit is contained in:
parent
83963f5994
commit
cd46c4944f
12
main.go
12
main.go
@ -79,9 +79,11 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
re := regexp.MustCompile(`(?i)((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)`)
|
re := regexp.MustCompile(`(?i)((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)`)
|
||||||
result := re.FindStringSubmatch(m.Content)
|
result := re.FindStringSubmatch(m.Content)
|
||||||
// hard coded, group 2 contains the base url
|
// hard coded, group 2 contains the base url
|
||||||
if result[2] == "https://www.reddit.com" || result[2] == "https://reddit.com"{
|
if len(result) >= 3 {
|
||||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://tedd.it%s>", result[4]))
|
if result[2] == "https://www.reddit.com" || result[2] == "https://reddit.com"{
|
||||||
} else if result[2] == "https://www.twitter.com" || result[2] == "https://twitter.com" {
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://tedd.it%s>", result[4]))
|
||||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://nitter.fly.dev%s>", result[4]))
|
} else if result[2] == "https://www.twitter.com" || result[2] == "https://twitter.com" {
|
||||||
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://nitter.it%s>", result[4]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user