fix: list command
This commit is contained in:
parent
18a373f083
commit
abe97aef28
5 changed files with 18 additions and 18 deletions
|
@ -43,10 +43,10 @@ var LearnedDataListCommand *Command = &Command{
|
||||||
},
|
},
|
||||||
Aliases: []string{"list", "목록", "지식목록"},
|
Aliases: []string{"list", "목록", "지식목록"},
|
||||||
DetailedDescription: &DetailedDescription{
|
DetailedDescription: &DetailedDescription{
|
||||||
Usage: fmt.Sprintf("%s리스트", configs.Config.Bot.Prefix),
|
Usage: fmt.Sprintf("%s리스트 [단어]", configs.Config.Bot.Prefix),
|
||||||
Examples: []string{
|
Examples: []string{
|
||||||
fmt.Sprintf("%s리스트", configs.Config.Bot.Prefix),
|
fmt.Sprintf("%s리스트", configs.Config.Bot.Prefix),
|
||||||
fmt.Sprintf("%s리스트 단어:안녕", configs.Config.Bot.Prefix),
|
fmt.Sprintf("%s리스트 안녕", configs.Config.Bot.Prefix),
|
||||||
fmt.Sprintf("%s리스트 개수:10", configs.Config.Bot.Prefix),
|
fmt.Sprintf("%s리스트 개수:10", configs.Config.Bot.Prefix),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -60,10 +60,12 @@ var LearnedDataListCommand *Command = &Command{
|
||||||
filter := bson.D{{Key: "user_id", Value: ctx.Msg.Author.ID}}
|
filter := bson.D{{Key: "user_id", Value: ctx.Msg.Author.ID}}
|
||||||
query := strings.Join(*ctx.Args, " ")
|
query := strings.Join(*ctx.Args, " ")
|
||||||
|
|
||||||
if match := utils.RegexpLearnQueryCommand.FindStringSubmatch(query); match != nil {
|
command := utils.RegexpLearnQueryLength.ReplaceAllString(query, "")
|
||||||
|
command = strings.Join(strings.Fields(command), " ")
|
||||||
|
if command != "" {
|
||||||
filter = append(filter, bson.E{
|
filter = append(filter, bson.E{
|
||||||
Key: "command",
|
Key: "command",
|
||||||
Value: match[1],
|
Value: command,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"git.wh64.net/muffin/goMuffin/utils"
|
"git.wh64.net/muffin/goMuffin/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MUFFIN_VERSION = "6.0.0-madeleine_develop.250712a"
|
const MUFFIN_VERSION = "6.0.0-madeleine_preview.250713a"
|
||||||
|
|
||||||
var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ func ExportData(n *commando.Node) error {
|
||||||
|
|
||||||
if refined {
|
if refined {
|
||||||
for i, text := range data {
|
for i, text := range data {
|
||||||
if utils.RegexpEmoji.Match([]byte(text.Text)) {
|
if utils.RegexpDiscordEmoji.Match([]byte(text.Text)) {
|
||||||
data = append(data[:i], data[i+1:]...)
|
data = append(data[:i], data[i+1:]...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,14 @@ func MakeDeleteLearnedData(id string, number int, userId string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDeleteLearnedDataId(customId string) (id bson.ObjectID, itemId int) {
|
func GetDeleteLearnedDataId(customId string) (id bson.ObjectID, itemId int) {
|
||||||
id, _ = bson.ObjectIDFromHex(strings.ReplaceAll(RegexpDLDId.FindAllString(customId, 1)[0], "id=", ""))
|
id, _ = bson.ObjectIDFromHex(strings.ReplaceAll(RegexpId.FindAllString(customId, 1)[0], "id=", ""))
|
||||||
stringItemId := strings.ReplaceAll(RegexpDLDItemId.FindAllString(customId, 1)[0], "no=", "")
|
stringItemId := strings.ReplaceAll(RegexpItemId.FindAllString(customId, 1)[0], "no=", "")
|
||||||
itemId, _ = strconv.Atoi(stringItemId)
|
itemId, _ = strconv.Atoi(stringItemId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDeleteLearnedDataUserId(customId string) string {
|
func GetDeleteLearnedDataUserId(customId string) string {
|
||||||
return strings.ReplaceAll(RegexpDLDUserId.FindAllString(customId, 1)[0], "user_id=", "")
|
return strings.ReplaceAll(RegexpUserId.FindAllString(customId, 1)[0], "user_id=", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakePaginationEmbedPrev(id string) string {
|
func MakePaginationEmbedPrev(id string) string {
|
||||||
|
@ -125,12 +125,12 @@ func MakeSelectChat(id string, number int, userId string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSelectChatId(customId string) (id bson.ObjectID, itemId int) {
|
func GetSelectChatId(customId string) (id bson.ObjectID, itemId int) {
|
||||||
id, _ = bson.ObjectIDFromHex(strings.ReplaceAll(RegexpDLDId.FindAllString(customId, 1)[0], "id=", ""))
|
id, _ = bson.ObjectIDFromHex(strings.ReplaceAll(RegexpId.FindAllString(customId, 1)[0], "id=", ""))
|
||||||
stringItemId := strings.ReplaceAll(RegexpDLDItemId.FindAllString(customId, 1)[0], "no=", "")
|
stringItemId := strings.ReplaceAll(RegexpItemId.FindAllString(customId, 1)[0], "no=", "")
|
||||||
itemId, _ = strconv.Atoi(stringItemId)
|
itemId, _ = strconv.Atoi(stringItemId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSelectChatUserId(customId string) string {
|
func GetSelectChatUserId(customId string) string {
|
||||||
return strings.ReplaceAll(RegexpDLDUserId.FindAllString(customId, 1)[0], "user_id=", "")
|
return strings.ReplaceAll(RegexpUserId.FindAllString(customId, 1)[0], "user_id=", "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,10 @@ import "regexp"
|
||||||
var (
|
var (
|
||||||
RegexpFlexibleString = regexp.MustCompile(`[^\s"'「」«»]+|"([^"]*)"|'([^']*)'|「([^」]*)」|«([^»]*)»`)
|
RegexpFlexibleString = regexp.MustCompile(`[^\s"'「」«»]+|"([^"]*)"|'([^']*)'|「([^」]*)」|«([^»]*)»`)
|
||||||
RegexpDecimals = regexp.MustCompile(`\d+`)
|
RegexpDecimals = regexp.MustCompile(`\d+`)
|
||||||
RegexpDLDItemId = regexp.MustCompile(`no=\d+`)
|
RegexpItemId = regexp.MustCompile(`no=\d+`)
|
||||||
RegexpDLDUserId = regexp.MustCompile(`user_id=\d+`)
|
RegexpUserId = regexp.MustCompile(`user_id=\d+`)
|
||||||
RegexpDLDId = regexp.MustCompile(`id=[^&]*`)
|
RegexpId = regexp.MustCompile(`id=[^&]*`)
|
||||||
RegexpEmoji = regexp.MustCompile(`<a?:\w+:\d+>`)
|
RegexpDiscordEmoji = regexp.MustCompile(`<a?:\w+:\d+>`)
|
||||||
RegexpLearnQueryCommand = regexp.MustCompile(`단어:([^\n대답개수:]*)`)
|
|
||||||
RegexpLearnQueryResult = regexp.MustCompile(`대답:([^\n단어개수:]*)`)
|
|
||||||
RegexpLearnQueryLength = regexp.MustCompile(`개수:(\d+)`)
|
RegexpLearnQueryLength = regexp.MustCompile(`개수:(\d+)`)
|
||||||
RegexpPaginationEmbedId = regexp.MustCompile(`^(\d+)/(\d+)$`)
|
RegexpPaginationEmbedId = regexp.MustCompile(`^(\d+)/(\d+)$`)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue