fix: block unregistered user's use muffin bot

This commit is contained in:
Siwoo Jeon 2025-06-21 10:04:50 +09:00
parent 3997617519
commit 11241231c9
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
7 changed files with 17 additions and 1 deletions

View file

@ -28,6 +28,7 @@ var ChatCommand *Command = &Command{
Category: Chatting, Category: Chatting,
RegisterApplicationCommand: true, RegisterApplicationCommand: true,
RegisterMessageCommand: false, RegisterMessageCommand: false,
Flags: CommandFlagsIsRegistered,
ChatInputRun: func(ctx *ChatInputContext) { ChatInputRun: func(ctx *ChatInputContext) {
i := ctx.Inter i := ctx.Inter
i.DeferReply(&discordgo.InteractionResponseData{}) i.DeferReply(&discordgo.InteractionResponseData{})

View file

@ -44,6 +44,7 @@ var DataLengthCommand *Command = &Command{
Category: General, Category: General,
RegisterApplicationCommand: true, RegisterApplicationCommand: true,
RegisterMessageCommand: true, RegisterMessageCommand: true,
Flags: CommandFlagsIsRegistered,
MessageRun: func(ctx *MsgContext) { MessageRun: func(ctx *MsgContext) {
dataLengthRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID) dataLengthRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID)
}, },

View file

@ -32,6 +32,7 @@ var DeleteLearnedDataCommand *Command = &Command{
Category: Chatting, Category: Chatting,
RegisterApplicationCommand: true, RegisterApplicationCommand: true,
RegisterMessageCommand: true, RegisterMessageCommand: true,
Flags: CommandFlagsIsRegistered,
MessageRun: func(ctx *MsgContext) { MessageRun: func(ctx *MsgContext) {
command := strings.Join(*ctx.Args, " ") command := strings.Join(*ctx.Args, " ")
if command == "" { if command == "" {

View file

@ -59,6 +59,7 @@ var LearnCommand *Command = &Command{
Category: Chatting, Category: Chatting,
RegisterApplicationCommand: true, RegisterApplicationCommand: true,
RegisterMessageCommand: true, RegisterMessageCommand: true,
Flags: CommandFlagsIsRegistered,
MessageRun: func(ctx *MsgContext) { MessageRun: func(ctx *MsgContext) {
if len(*ctx.Args) < 2 { if len(*ctx.Args) < 2 {
utils.NewMessageSender(ctx.Msg). utils.NewMessageSender(ctx.Msg).

View file

@ -53,6 +53,7 @@ var LearnedDataListCommand *Command = &Command{
Category: Chatting, Category: Chatting,
RegisterApplicationCommand: true, RegisterApplicationCommand: true,
RegisterMessageCommand: true, RegisterMessageCommand: true,
Flags: CommandFlagsIsRegistered,
MessageRun: func(ctx *MsgContext) { MessageRun: func(ctx *MsgContext) {
var length int var length int

View file

@ -7,7 +7,7 @@ import (
"git.wh64.net/muffin/goMuffin/utils" "git.wh64.net/muffin/goMuffin/utils"
) )
const MUFFIN_VERSION = "0.0.0-madeleine_canary.250620a" const MUFFIN_VERSION = "0.0.0-madeleine_canary.250621a"
var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0] var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]

View file

@ -38,6 +38,17 @@ func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
command := commands.Discommand.Aliases[args[0]] command := commands.Discommand.Aliases[args[0]]
if command == "" || command == "대화" { if command == "" || command == "대화" {
if !databases.Database.IsUser(m.Author.ID) {
utils.NewMessageSender(&utils.MessageCreate{
MessageCreate: m,
Session: s,
}).
AddComponents(utils.GetUserIsNotRegisteredErrContainer(configs.Config.Bot.Prefix)).
SetComponentsV2(true).
SetReply(true).
Send()
return
}
s.ChannelTyping(m.ChannelID) s.ChannelTyping(m.ChannelID)
str, err := chatbot.ChatBot.GetResponse(m.Author, strings.TrimPrefix(content, "대화 ")) str, err := chatbot.ChatBot.GetResponse(m.Author, strings.TrimPrefix(content, "대화 "))