mirror of
https://github.com/fumiama/NanoBot.git
synced 2026-06-06 03:00:24 +08:00
optimize: generate
This commit is contained in:
104
api_generated.go
104
api_generated.go
@@ -2,7 +2,7 @@
|
||||
|
||||
package nano
|
||||
|
||||
// 生成自文件 openapi_announces.go
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_announces.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// PostAnnounceInGuild 创建频道全局公告,公告类型分为 消息类型的频道公告 和 推荐子频道类型的频道公告
|
||||
//
|
||||
@@ -21,7 +21,10 @@ func (ctx *Ctx) PostAnnounceInGuild(id string, content *Announces) error {
|
||||
func (ctx *Ctx) DeleteAnnounceInGuild(guildid, messageid string) error {
|
||||
return ctx.caller.DeleteAnnounceInGuild(guildid, messageid)
|
||||
}
|
||||
// 生成自文件 openapi_audio.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_announces.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_audio.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// ControlAudioInChannel 控制子频道 channel_id 下的音频
|
||||
//
|
||||
@@ -43,7 +46,10 @@ func (ctx *Ctx) OpenMicInChannel(id string) error {
|
||||
func (ctx *Ctx) CloseMicInChannel(id string) error {
|
||||
return ctx.caller.CloseMicInChannel(id)
|
||||
}
|
||||
// 生成自文件 openapi_channel.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_audio.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_channel.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetChannelsOfGuild 获取 guild_id 指定的频道下的子频道列表
|
||||
//
|
||||
@@ -114,11 +120,26 @@ func (ctx *Ctx) GetChannelPermissionsOfRole(channelid, roleid string) (*ChannelP
|
||||
func (ctx *Ctx) SetChannelPermissionsOfRole(channelid, roleid string, add, remove string) error {
|
||||
return ctx.caller.SetChannelPermissionsOfRole(channelid, roleid, add, remove)
|
||||
}
|
||||
// 生成自文件 openapi_codegen_getopenapiof.go
|
||||
// 生成自文件 openapi_codegen_patchopenapiof.go
|
||||
// 生成自文件 openapi_codegen_postopenapiof.go
|
||||
// 生成自文件 openapi_codegen_putopenapiof.go
|
||||
// 生成自文件 openapi_dms.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_channel.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_codegen_getopenapiof.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_codegen_getopenapiof.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_codegen_patchopenapiof.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_codegen_patchopenapiof.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_codegen_postopenapiof.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_codegen_postopenapiof.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_codegen_putopenapiof.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_codegen_putopenapiof.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_dms.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// CreatePrivateChat 机器人和在同一个频道内的成员创建私信会话
|
||||
//
|
||||
@@ -142,7 +163,10 @@ func (ctx *Ctx) PostMessageToUser(id string, content *MessagePost) (*Message, er
|
||||
func (ctx *Ctx) DeleteMessageOfUser(guildid, messageid string, hidetip bool) error {
|
||||
return ctx.caller.DeleteMessageOfUser(guildid, messageid, hidetip)
|
||||
}
|
||||
// 生成自文件 openapi_emoji.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_dms.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_emoji.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GiveMessageReaction 对消息 message_id 进行表情表态
|
||||
//
|
||||
@@ -164,7 +188,10 @@ func (ctx *Ctx) DeleteMessageReaction(channelid, messageid string, emoji Emoji)
|
||||
func (ctx *Ctx) GetMessageReactionUsers(channelid, messageid string, emoji Emoji, cookie string, limit int) (*MessageReactionUsers, error) {
|
||||
return ctx.caller.GetMessageReactionUsers(channelid, messageid, emoji, cookie, limit)
|
||||
}
|
||||
// 生成自文件 openapi_forum.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_emoji.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_forum.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetChannelThreads 获取子频道下的帖子列表
|
||||
//
|
||||
@@ -193,7 +220,10 @@ func (ctx *Ctx) PostThreadInChannel(id string, title string, content string, for
|
||||
func (ctx *Ctx) DeleteThreadInChannel(channelid, threadid string) error {
|
||||
return ctx.caller.DeleteThreadInChannel(channelid, threadid)
|
||||
}
|
||||
// 生成自文件 openapi_guild.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_forum.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_guild.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetGuildByID 获取 guild_id 指定的频道的详情
|
||||
//
|
||||
@@ -222,8 +252,14 @@ func (ctx *Ctx) SetUserMuteInGuild(guildid, userid string, endtimestamp string,
|
||||
func (ctx *Ctx) SetUsersMuteInGuild(guildid string, endtimestamp string, seconds string, userids ...string) ([]string, error) {
|
||||
return ctx.caller.SetUsersMuteInGuild(guildid, endtimestamp, seconds, userids...)
|
||||
}
|
||||
// 生成自文件 openapi_markdown.go
|
||||
// 生成自文件 openapi_member.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_guild.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_markdown.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_markdown.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_member.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetGuildMembersIn 获取 guild_id 指定的频道中所有成员的详情列表,支持分页
|
||||
//
|
||||
@@ -254,7 +290,10 @@ func (ctx *Ctx) GetGuildMemberOf(guildid, userid string) (*Member, error) {
|
||||
func (ctx *Ctx) DeleteGuildMemberOf(guildid, userid string, addblklst bool, delhistmsgdays int) error {
|
||||
return ctx.caller.DeleteGuildMemberOf(guildid, userid, addblklst, delhistmsgdays)
|
||||
}
|
||||
// 生成自文件 openapi_message.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_member.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_message.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetMessageFromChannel 获取子频道 channel_id 下的消息 message_id 的详情
|
||||
//
|
||||
@@ -283,8 +322,14 @@ func (ctx *Ctx) DeleteMessageInChannel(channelid, messageid string, hidetip bool
|
||||
func (ctx *Ctx) GetGuildMessageSetting(id string) (*MessageSetting, error) {
|
||||
return ctx.caller.GetGuildMessageSetting(id)
|
||||
}
|
||||
// 生成自文件 openapi_permissions.go
|
||||
// 生成自文件 openapi_pins.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_message.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_permissions.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_permissions.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_pins.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// PinMessageInChannel 添加子频道 channel_id 内的精华消息
|
||||
//
|
||||
@@ -308,8 +353,14 @@ func (ctx *Ctx) UnpinMessageInChannel(channelid, messageid string) error {
|
||||
func (ctx *Ctx) GetPinMessagesOfChannel(id string) (*PinsMessage, error) {
|
||||
return ctx.caller.GetPinMessagesOfChannel(id)
|
||||
}
|
||||
// 生成自文件 openapi_richobj.go
|
||||
// 生成自文件 openapi_role.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_pins.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_richobj.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_richobj.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_role.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetGuildRoleListIn 获取 guild_id 指定的频道下的身份组列表
|
||||
//
|
||||
@@ -356,7 +407,10 @@ func (ctx *Ctx) AddRoleToMemberOfGuild(guildid, userid, roleid, channelid string
|
||||
func (ctx *Ctx) RemoveRoleFromMemberOfGuild(guildid, userid, roleid, channelid string) error {
|
||||
return ctx.caller.RemoveRoleFromMemberOfGuild(guildid, userid, roleid, channelid)
|
||||
}
|
||||
// 生成自文件 openapi_schedule.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_role.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_schedule.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetChannelSchedules 获取channel_id指定的子频道中当天的日程列表
|
||||
//
|
||||
@@ -396,7 +450,10 @@ func (ctx *Ctx) PatchScheduleInChannel(channelid string, scheduleid string, sche
|
||||
func (ctx *Ctx) DeleteScheduleInChannel(channelid string, scheduleid string) error {
|
||||
return ctx.caller.DeleteScheduleInChannel(channelid, scheduleid)
|
||||
}
|
||||
// 生成自文件 openapi_user.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_schedule.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_user.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// AtMe 返回 <@!bot.ready.User.ID>
|
||||
func (ctx *Ctx) AtMe() string {
|
||||
@@ -416,7 +473,10 @@ func (ctx *Ctx) GetMyInfo() (*User, error) {
|
||||
func (ctx *Ctx) GetMyGuilds(before, after string, limit int) (guilds []Guild, err error) {
|
||||
return ctx.caller.GetMyGuilds(before, after, limit)
|
||||
}
|
||||
// 生成自文件 openapi_wss.go
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_user.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
/* vvvvvvvvvvvvvvvvvvvv 生成自文件 openapi_wss.go vvvvvvvvvvvvvvvvvvvvv */
|
||||
|
||||
// GetGeneralWSSGateway 获取通用 WSS 接入点
|
||||
//
|
||||
@@ -431,3 +491,5 @@ func (ctx *Ctx) GetGeneralWSSGateway() (string, error) {
|
||||
func (ctx *Ctx) GetShardWSSGateway() (*ShardWSSGateway, error) {
|
||||
return ctx.caller.GetShardWSSGateway()
|
||||
}
|
||||
|
||||
/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 openapi_wss.go ^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
@@ -22,7 +22,6 @@ func main() {
|
||||
f.WriteString(`// Code generated by codegen/context. DO NOT EDIT.
|
||||
|
||||
package nano
|
||||
|
||||
`)
|
||||
err = fs.WalkDir(os.DirFS("./"), ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
@@ -35,9 +34,9 @@ package nano
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f.WriteString("// 生成自文件 ")
|
||||
f.WriteString("\n/* vvvvvvvvvvvvvvvvvvvv 生成自文件 ")
|
||||
f.WriteString(path)
|
||||
f.WriteString("\n")
|
||||
f.WriteString(" vvvvvvvvvvvvvvvvvvvvv */\n")
|
||||
for _, define := range apire.FindAllStringSubmatch(nano.BytesToString(data), -1) {
|
||||
f.WriteString(define[1]) // 注释
|
||||
f.WriteString("func (ctx *Ctx) ") // 函数声明
|
||||
@@ -72,6 +71,9 @@ package nano
|
||||
}
|
||||
f.WriteString(")\n}\n")
|
||||
}
|
||||
f.WriteString("\n/* ^^^^^^^^^^^^^^^^^^^^ 生成自文件 ")
|
||||
f.WriteString(path)
|
||||
f.WriteString(" ^^^^^^^^^^^^^^^^^^^^ */\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -56,14 +56,14 @@ ruleon:
|
||||
Message:
|
||||
- Message
|
||||
Rule:
|
||||
Prefix: [prefix, string]
|
||||
Suffix: [suffix, string]
|
||||
Command: [commands, string]
|
||||
Regex: [regexPattern, string]
|
||||
Keyword: [keyword, string]
|
||||
FullMatch: [src, string]
|
||||
FullMatchGroup: [src, "[]string"]
|
||||
KeywordGroup: [keywords, "[]string"]
|
||||
CommandGroup: [commands, "[]string"]
|
||||
PrefixGroup: [prefix, "[]string"]
|
||||
SuffixGroup: [suffix, "[]string"]
|
||||
- [Prefix, prefix, string]
|
||||
- [Suffix, suffix, string]
|
||||
- [Command, commands, string]
|
||||
- [Regex, regexPattern, string]
|
||||
- [Keyword, keyword, string]
|
||||
- [FullMatch, src, string]
|
||||
- [FullMatchGroup, src, "[]string"]
|
||||
- [KeywordGroup, keywords, "[]string"]
|
||||
- [CommandGroup, commands, "[]string"]
|
||||
- [PrefixGroup, prefix, "[]string"]
|
||||
- [SuffixGroup, suffix, "[]string"]
|
||||
|
||||
@@ -59,8 +59,8 @@ func (e *Engine) On[Message]Shell(command string, model interface{}, rules ...Ru
|
||||
type config struct {
|
||||
EmptyOn []string `yaml:"emptyon"`
|
||||
RuleOn struct {
|
||||
Message []string `yaml:"Message"`
|
||||
Rule map[string][2]string `yaml:"Rule"`
|
||||
Message []string `yaml:"Message"`
|
||||
Rule [][3]string `yaml:"Rule"`
|
||||
} `yaml:"ruleon"`
|
||||
}
|
||||
|
||||
@@ -91,12 +91,12 @@ func main() {
|
||||
}
|
||||
}
|
||||
for _, msg := range cfg.RuleOn.Message {
|
||||
for rule, x := range cfg.RuleOn.Rule {
|
||||
for _, x := range cfg.RuleOn.Rule {
|
||||
s := strings.ReplaceAll(ruleon, "[Message]", msg)
|
||||
s = strings.ReplaceAll(s, "[Rule]", rule)
|
||||
s = strings.ReplaceAll(s, "[Name]", x[0])
|
||||
s = strings.ReplaceAll(s, "[Type]", x[1])
|
||||
if strings.Contains(rule, "Group") {
|
||||
s = strings.ReplaceAll(s, "[Rule]", x[0])
|
||||
s = strings.ReplaceAll(s, "[Name]", x[1])
|
||||
s = strings.ReplaceAll(s, "[Type]", x[2])
|
||||
if strings.Contains(x[0], "Group") {
|
||||
s = strings.ReplaceAll(s, "[...]", "...")
|
||||
} else {
|
||||
s = strings.ReplaceAll(s, "[...]", "")
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
//go:generate go run codegen/context/main.go
|
||||
|
||||
type Ctx struct {
|
||||
Event
|
||||
State
|
||||
|
||||
@@ -248,54 +248,6 @@ func (e *Engine) OnPublicMessageDelete(rules ...Rule) *Matcher { return e.On("Pu
|
||||
// OnPublicMessageDelete ...
|
||||
func OnPublicMessageDelete(rules ...Rule) *Matcher { return On("PublicMessageDelete", rules...) }
|
||||
|
||||
// OnMessageKeyword ...
|
||||
func OnMessageKeyword(keyword string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageKeyword(keyword, rules...)
|
||||
}
|
||||
|
||||
// OnMessageKeyword ...
|
||||
func (e *Engine) OnMessageKeyword(keyword string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{KeywordRule(keyword)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageCommandGroup ...
|
||||
func OnMessageCommandGroup(commands []string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageCommandGroup(commands, rules...)
|
||||
}
|
||||
|
||||
// OnMessageCommandGroup ...
|
||||
func (e *Engine) OnMessageCommandGroup(commands []string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{CommandGroupRule(commands...)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageSuffixGroup ...
|
||||
func OnMessageSuffixGroup(suffix []string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageSuffixGroup(suffix, rules...)
|
||||
}
|
||||
|
||||
// OnMessageSuffixGroup ...
|
||||
func (e *Engine) OnMessageSuffixGroup(suffix []string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{SuffixGroupRule(suffix...)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessagePrefix ...
|
||||
func OnMessagePrefix(prefix string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessagePrefix(prefix, rules...)
|
||||
@@ -312,6 +264,38 @@ func (e *Engine) OnMessagePrefix(prefix string, rules ...Rule) *Matcher {
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageSuffix ...
|
||||
func OnMessageSuffix(suffix string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageSuffix(suffix, rules...)
|
||||
}
|
||||
|
||||
// OnMessageSuffix ...
|
||||
func (e *Engine) OnMessageSuffix(suffix string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{SuffixRule(suffix)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageCommand ...
|
||||
func OnMessageCommand(commands string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageCommand(commands, rules...)
|
||||
}
|
||||
|
||||
// OnMessageCommand ...
|
||||
func (e *Engine) OnMessageCommand(commands string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{CommandRule(commands)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageRegex ...
|
||||
func OnMessageRegex(regexPattern string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageRegex(regexPattern, rules...)
|
||||
@@ -328,6 +312,22 @@ func (e *Engine) OnMessageRegex(regexPattern string, rules ...Rule) *Matcher {
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageKeyword ...
|
||||
func OnMessageKeyword(keyword string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageKeyword(keyword, rules...)
|
||||
}
|
||||
|
||||
// OnMessageKeyword ...
|
||||
func (e *Engine) OnMessageKeyword(keyword string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{KeywordRule(keyword)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageFullMatch ...
|
||||
func OnMessageFullMatch(src string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageFullMatch(src, rules...)
|
||||
@@ -376,6 +376,22 @@ func (e *Engine) OnMessageKeywordGroup(keywords []string, rules ...Rule) *Matche
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageCommandGroup ...
|
||||
func OnMessageCommandGroup(commands []string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageCommandGroup(commands, rules...)
|
||||
}
|
||||
|
||||
// OnMessageCommandGroup ...
|
||||
func (e *Engine) OnMessageCommandGroup(commands []string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{CommandGroupRule(commands...)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessagePrefixGroup ...
|
||||
func OnMessagePrefixGroup(prefix []string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessagePrefixGroup(prefix, rules...)
|
||||
@@ -392,32 +408,16 @@ func (e *Engine) OnMessagePrefixGroup(prefix []string, rules ...Rule) *Matcher {
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageSuffix ...
|
||||
func OnMessageSuffix(suffix string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageSuffix(suffix, rules...)
|
||||
// OnMessageSuffixGroup ...
|
||||
func OnMessageSuffixGroup(suffix []string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageSuffixGroup(suffix, rules...)
|
||||
}
|
||||
|
||||
// OnMessageSuffix ...
|
||||
func (e *Engine) OnMessageSuffix(suffix string, rules ...Rule) *Matcher {
|
||||
// OnMessageSuffixGroup ...
|
||||
func (e *Engine) OnMessageSuffixGroup(suffix []string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{SuffixRule(suffix)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
return StoreMatcher(matcher)
|
||||
}
|
||||
|
||||
// OnMessageCommand ...
|
||||
func OnMessageCommand(commands string, rules ...Rule) *Matcher {
|
||||
return defaultEngine.OnMessageCommand(commands, rules...)
|
||||
}
|
||||
|
||||
// OnMessageCommand ...
|
||||
func (e *Engine) OnMessageCommand(commands string, rules ...Rule) *Matcher {
|
||||
matcher := &Matcher{
|
||||
Type: "Message",
|
||||
Rules: append([]Rule{CommandRule(commands)}, rules...),
|
||||
Rules: append([]Rule{SuffixGroupRule(suffix...)}, rules...),
|
||||
Engine: e,
|
||||
}
|
||||
e.matchers = append(e.matchers, matcher)
|
||||
|
||||
Reference in New Issue
Block a user