Skip to content

Commit

Permalink
Merge branch 'release/3.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
j4rv committed Apr 16, 2024
2 parents d138b8f + 5f08d8e commit 5fbb40f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/jarvbot/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
const roleEveryone = "@everyone"
const globalGuildID = ""

var ogNonRootTwitterLinkRegex = regexp.MustCompile(`\b(?:https?://)?(?:www\.)?(?:twitter|x)\.com/\S+\b`)
var ogTwitterLinkRegex = regexp.MustCompile(`\b(?:https?://)?(?:www\.)?(?:twitter|x)\.com\b`)
var commandPrefixRegex = regexp.MustCompile(`^!\w+\s*`)
var commandWithTwoArguments = regexp.MustCompile(`^!\w+\s*(\(.{1,36}\))\s*(\(.{1,36}\))`)
Expand All @@ -46,7 +47,7 @@ func onMessageCreated(ctx context.Context) func(ds *discordgo.Session, mc *disco
}

// Twitter links replacement
if ogTwitterLinkRegex.MatchString(mc.Content) {
if ogNonRootTwitterLinkRegex.MatchString(mc.Content) {
processMessageWithTwitterLinks(ds, mc, ctx)
return
}
Expand All @@ -56,7 +57,7 @@ func onMessageCreated(ctx context.Context) func(ds *discordgo.Session, mc *disco
// the command key must be lowercased
var commands = map[string]command{
// public
"!version": simpleTextResponse("v3.6.0"),
"!version": simpleTextResponse("v3.6.1"),
"!source": simpleTextResponse("Source code: https://github.com/j4rv/discord-bot"),
"!genshindailycheckin": answerGenshinDailyCheckIn,
"!genshindailycheckinstop": answerGenshinDailyCheckInStop,
Expand Down Expand Up @@ -263,7 +264,10 @@ func processMessageWithTwitterLinks(ds *discordgo.Session, mc *discordgo.Message

messageContent := ogTwitterLinkRegex.ReplaceAllString(mc.Content, "https://fxtwitter.com")
messageContent = fmt.Sprintf("%s:\n%s", mc.Author.Mention(), messageContent)
_, err := ds.ChannelMessageSend(mc.ChannelID, messageContent)
_, err := ds.ChannelMessageSendComplex(mc.ChannelID, &discordgo.MessageSend{
Content: messageContent,
AllowedMentions: &discordgo.MessageAllowedMentions{},
})
if err != nil {
notifyIfErr("processMessageWithTwitterLinks::ds.ChannelMessageSend", err, ds)
return
Expand Down

0 comments on commit 5fbb40f

Please sign in to comment.