From ebb4af1f862716db624f561557c4da4158b0af34 Mon Sep 17 00:00:00 2001 From: axiangcoding Date: Tue, 21 Feb 2023 21:35:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-system/cmd/cardfight/main.go | 2 +- api-system/internal/service/bot_service.go | 24 +++++++++---------- api-system/internal/service/cqhttp_service.go | 6 ++--- api-system/pkg/cqhttp/api.go | 2 ++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/api-system/cmd/cardfight/main.go b/api-system/cmd/cardfight/main.go index 054596b..a12d591 100644 --- a/api-system/cmd/cardfight/main.go +++ b/api-system/cmd/cardfight/main.go @@ -5,7 +5,7 @@ import ( "github.com/axiangcoding/antonstar-bot/pkg/cardfight" ) -// WIP 卡牌对战程序 +// TODO 卡牌对战程序 func main() { card99A := cardfight.InitCarItem("ZTZ99A", "用户一号", 10, 9, 7, 6) cardL2A6 := cardfight.InitCarItem("豹2A6", "用户二号", 10, 7, 8, 6) diff --git a/api-system/internal/service/bot_service.go b/api-system/internal/service/bot_service.go index b3cc8f9..21b6bfd 100644 --- a/api-system/internal/service/bot_service.go +++ b/api-system/internal/service/bot_service.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" "github.com/axiangcoding/antonstar-bot/internal/data/display" - table2 "github.com/axiangcoding/antonstar-bot/internal/data/table" + "github.com/axiangcoding/antonstar-bot/internal/data/table" "github.com/axiangcoding/antonstar-bot/pkg/bot" "github.com/axiangcoding/antonstar-bot/pkg/cqhttp" "github.com/axiangcoding/antonstar-bot/pkg/crawler" @@ -70,21 +70,21 @@ func RefreshWTUserInfo(nickname string, sendForm cqhttp.SendGroupMsgForm) (*stri SendForm: sendForm, Nick: nickname, } - if err := SubmitMissionWithDetail(missionId, table2.MissionTypeUserInfo, form); err != nil { + if err := SubmitMissionWithDetail(missionId, table.MissionTypeUserInfo, form); err != nil { return nil, err } if err := ants.Submit(func() { if err := crawler.GetProfileFromWTOfficial(nickname, - func(status int, user *table2.GameUser) { + func(status int, user *table.GameUser) { switch status { case crawler.StatusQueryFailed: - MustFinishMissionWithResult(missionId, table2.MissionStatusFailed, CrawlerResult{ + MustFinishMissionWithResult(missionId, table.MissionStatusFailed, CrawlerResult{ Found: false, Nick: nickname, }) case crawler.StatusNotFound: MustPutRefreshFlag(nickname) - MustFinishMissionWithResult(missionId, table2.MissionStatusSuccess, CrawlerResult{ + MustFinishMissionWithResult(missionId, table.MissionStatusSuccess, CrawlerResult{ Found: false, Nick: nickname, }) @@ -115,7 +115,7 @@ func RefreshWTUserInfo(nickname string, sendForm cqhttp.SendGroupMsgForm) (*stri logging.L().Warn("failed on update thunder skill profile. ", logging.Error(err)) } MustPutRefreshFlag(nickname) - MustFinishMissionWithResult(missionId, table2.MissionStatusSuccess, CrawlerResult{ + MustFinishMissionWithResult(missionId, table.MissionStatusSuccess, CrawlerResult{ Found: true, Nick: nickname, Data: *user}, @@ -300,7 +300,7 @@ func DoActionUnbinding(retMsgForm *cqhttp.SendGroupMsgForm) { retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.UnbindingSuccess } -func DoActionManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table2.QQUserConfig, value string) { +func DoActionManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table.QQUserConfig, value string) { // 只有超级管理员可以进行全局设置 if uc.SuperAdmin == nil || !*uc.SuperAdmin { retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.ConfNotPermit @@ -315,16 +315,16 @@ func DoActionManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table2.QQUserConfi keyUnsetAdmin := "解除管理员" switch value { case keyOpenResponse: - MustUpsertGlobalConfig(table2.ConfigStopAllResponse, "false") + MustUpsertGlobalConfig(table.ConfigStopAllResponse, "false") retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.ConfStartGlobalResponse case keyCloseResponse: - MustUpsertGlobalConfig(table2.ConfigStopAllResponse, "true") + MustUpsertGlobalConfig(table.ConfigStopAllResponse, "true") retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.ConfStopGlobalResponse case keyOpenQuery: - MustUpsertGlobalConfig(table2.ConfigStopQuery, "false") + MustUpsertGlobalConfig(table.ConfigStopQuery, "false") retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.ConfStartGlobalQuery case keyCloseQuery: - MustUpsertGlobalConfig(table2.ConfigStopQuery, "true") + MustUpsertGlobalConfig(table.ConfigStopQuery, "true") retMsgForm.Message = bot.SelectStaticMessage(retMsgForm.MessageTemplate).CommonResp.ConfStopGlobalQuery case keySetAdmin: // TODO @@ -342,6 +342,6 @@ func DoActionManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table2.QQUserConfi } } -func DoActionGroupManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table2.QQUserConfig, value string) { +func DoActionGroupManager(retMsgForm *cqhttp.SendGroupMsgForm, uc *table.QQUserConfig, value string) { // TODO 群管理 } diff --git a/api-system/internal/service/cqhttp_service.go b/api-system/internal/service/cqhttp_service.go index 8cc2b72..b382611 100644 --- a/api-system/internal/service/cqhttp_service.go +++ b/api-system/internal/service/cqhttp_service.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" "github.com/axiangcoding/antonstar-bot/internal/cache" - table2 "github.com/axiangcoding/antonstar-bot/internal/data/table" + "github.com/axiangcoding/antonstar-bot/internal/data/table" "github.com/axiangcoding/antonstar-bot/pkg/bot" "github.com/axiangcoding/antonstar-bot/pkg/cqhttp" "github.com/axiangcoding/antonstar-bot/pkg/logging" @@ -111,7 +111,7 @@ func handleCqHttpMessageEventGroup(event *cqhttp.CommonEvent) { gc, err := FindGroupConfig(groupId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - defaultGC := table2.DefaultGroupConfig(groupId) + defaultGC := table.DefaultGroupConfig(groupId) gc = &defaultGC MustSaveGroupConfig(gc) } else { @@ -121,7 +121,7 @@ func handleCqHttpMessageEventGroup(event *cqhttp.CommonEvent) { uc, err := FindUserConfig(userId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - defaultUC := table2.DefaultUserConfig(userId) + defaultUC := table.DefaultUserConfig(userId) uc = &defaultUC MustSaveUserConfig(uc) } else { diff --git a/api-system/pkg/cqhttp/api.go b/api-system/pkg/cqhttp/api.go index 3f5691f..1d65e7f 100644 --- a/api-system/pkg/cqhttp/api.go +++ b/api-system/pkg/cqhttp/api.go @@ -8,6 +8,7 @@ import ( ) // MustSendGroupMsg +// TODO 将配置项外移,不在最终方法中调用 // https://docs.go-cqhttp.org/api/#%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82-%E9%82%80%E8%AF%B7 func MustSendGroupMsg(form SendGroupMsgForm) { url := setting.C().App.Service.CqHttp.Url + "/send_group_msg" @@ -33,6 +34,7 @@ func MustSendGroupMsg(form SendGroupMsgForm) { } // MustAcceptInviteToGroup +// TODO 将配置项外移,不在最终方法中调用 // https://docs.go-cqhttp.org/api/#%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82-%E9%82%80%E8%AF%B7 func MustAcceptInviteToGroup(flag string, subType string, approve bool, reason string) { url := setting.C().App.Service.CqHttp.Url + "/set_group_add_request"