From f4698f4716d99f2de96762ad360d703906057ab1 Mon Sep 17 00:00:00 2001 From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:41:22 +0800 Subject: [PATCH] Beta461 (#462) * beta447 * beta448 * beta449 * beta450 * beta451 * beta452 * beta453 * beta454 * beta455 * btea455 * beta456 * beta457 * beta458 * beta460 * beta460 * beta461 --- config/config.go | 582 ++++++++++++++++++------------------ structs/structs.go | 7 +- template/config_template.go | 3 +- wsclient/ws.go | 4 +- 4 files changed, 306 insertions(+), 290 deletions(-) diff --git a/config/config.go b/config/config.go index 8aa180ef..e2da9a17 100644 --- a/config/config.go +++ b/config/config.go @@ -20,7 +20,7 @@ import ( var ( instance *Config - mu sync.Mutex + mu sync.RWMutex ) type Config struct { @@ -585,8 +585,8 @@ func DeleteConfig() error { // 获取ws地址数组 func GetWsAddress() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.WsAddress } @@ -595,8 +595,8 @@ func GetWsAddress() []string { // 获取gensokyo服务的地址 func GetServer_dir() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get upload directory.") @@ -607,8 +607,8 @@ func GetServer_dir() string { // 获取DevBotid func GetDevBotid() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get DevBotid.") @@ -619,8 +619,8 @@ func GetDevBotid() string { // 获取GetForwardMsgLimit func GetForwardMsgLimit() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get GetForwardMsgLimit.") @@ -631,8 +631,8 @@ func GetForwardMsgLimit() int { // 获取Develop_Acdir服务的地址 func GetDevelop_Acdir() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get DevlopAcDir.") @@ -643,8 +643,8 @@ func GetDevelop_Acdir() string { // 获取lotus的值 func GetLotusValue() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get lotus value.") @@ -655,8 +655,8 @@ func GetLotusValue() bool { // 获取双向ehco func GetTwoWayEcho() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get lotus value.") @@ -667,8 +667,8 @@ func GetTwoWayEcho() bool { // 获取白名单开启状态 func GetWhitePrefixMode() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetWhitePrefixModes value.") @@ -679,8 +679,8 @@ func GetWhitePrefixMode() bool { // 获取白名单指令数组 func GetWhitePrefixs() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.WhitePrefixs } @@ -689,8 +689,8 @@ func GetWhitePrefixs() []string { // 获取黑名单开启状态 func GetBlackPrefixMode() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetBlackPrefixMode value.") @@ -701,8 +701,8 @@ func GetBlackPrefixMode() bool { // 获取黑名单指令数组 func GetBlackPrefixs() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.BlackPrefixs } @@ -711,8 +711,8 @@ func GetBlackPrefixs() []string { // 获取IPurl显示开启状态 func GetVisibleIP() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetVisibleIP value.") @@ -723,8 +723,8 @@ func GetVisibleIP() bool { // 修改 GetVisualkPrefixs 函数以返回新类型 func GetVisualkPrefixs() []structs.VisualPrefixConfig { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { var varvisualPrefixes []structs.VisualPrefixConfig for _, vp := range instance.Settings.VisualPrefixs { @@ -741,8 +741,8 @@ func GetVisualkPrefixs() []structs.VisualPrefixConfig { // 获取LazyMessageId状态 func GetLazyMessageId() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LazyMessageId value.") @@ -753,8 +753,8 @@ func GetLazyMessageId() bool { // 获取HashID func GetHashIDValue() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get hashid value.") @@ -765,8 +765,8 @@ func GetHashIDValue() bool { // 获取RemoveAt的值 func GetRemoveAt() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get RemoveAt value.") @@ -777,8 +777,8 @@ func GetRemoveAt() bool { // 获取port的值 func GetPortValue() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get port value.") @@ -789,8 +789,8 @@ func GetPortValue() string { // 获取Array的值 func GetArrayValue() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get array value.") @@ -801,8 +801,8 @@ func GetArrayValue() bool { // 获取AppID func GetAppID() uint64 { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.AppID } @@ -811,8 +811,8 @@ func GetAppID() uint64 { // 获取AppID String func GetAppIDStr() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return fmt.Sprintf("%d", instance.Settings.AppID) } @@ -821,8 +821,8 @@ func GetAppIDStr() string { // 获取WsToken func GetWsToken() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.WsToken } @@ -831,8 +831,8 @@ func GetWsToken() []string { // 获取MasterID数组 func GetMasterID() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.MasterID } @@ -841,8 +841,8 @@ func GetMasterID() []string { // 获取port的值 func GetEnableWsServer() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get port value.") @@ -853,8 +853,8 @@ func GetEnableWsServer() bool { // 获取WsServerToken的值 func GetWsServerToken() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get WsServerToken value.") @@ -865,8 +865,8 @@ func GetWsServerToken() string { // 获取identify_file的值 func GetIdentifyFile() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get identify file name.") @@ -877,8 +877,8 @@ func GetIdentifyFile() bool { // 获取crt路径 func GetCrtPath() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get crt path.") @@ -889,8 +889,8 @@ func GetCrtPath() string { // 获取key路径 func GetKeyPath() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get key path.") @@ -901,8 +901,8 @@ func GetKeyPath() string { // 开发者日志 func GetDeveloperLog() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get developer log status.") @@ -957,8 +957,8 @@ func ComposeWebUIURLv2(useBackupPort bool) string { // GetServerUserName 获取服务器用户名 func GetServerUserName() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get server user name.") @@ -969,8 +969,8 @@ func GetServerUserName() string { // GetServerUserPassword 获取服务器用户密码 func GetServerUserPassword() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get server user password.") @@ -981,8 +981,8 @@ func GetServerUserPassword() string { // GetImageLimit 返回 ImageLimit 的值 func GetImageLimit() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get image limit value.") @@ -994,8 +994,8 @@ func GetImageLimit() int { // GetRemovePrefixValue 函数用于获取 remove_prefix 的配置值 func GetRemovePrefixValue() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get remove_prefix value.") @@ -1006,8 +1006,8 @@ func GetRemovePrefixValue() bool { // GetLotusPort retrieves the LotusPort setting from your singleton instance. func GetBackupPort() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LotusPort.") @@ -1019,8 +1019,8 @@ func GetBackupPort() string { // 获取GetDevMsgID的值 func GetDevMsgID() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetDevMsgID value.") @@ -1031,8 +1031,8 @@ func GetDevMsgID() bool { // 获取GetSaveLogs的值 func GetSaveLogs() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetSaveLogs value.") @@ -1043,8 +1043,8 @@ func GetSaveLogs() bool { // 获取GetSaveLogs的值 func GetLogLevel() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetLogLevel value.") @@ -1055,8 +1055,8 @@ func GetLogLevel() int { // 获取GetBindPrefix的值 func GetBindPrefix() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetBindPrefix value.") @@ -1067,8 +1067,8 @@ func GetBindPrefix() string { // 获取GetMePrefix的值 func GetMePrefix() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetMePrefix value.") @@ -1079,8 +1079,8 @@ func GetMePrefix() string { // 获取FrpPort的值 func GetFrpPort() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetFrpPort value.") @@ -1091,8 +1091,8 @@ func GetFrpPort() string { // 获取GetRemoveBotAtGroup的值 func GetRemoveBotAtGroup() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetRemoveBotAtGroup value.") @@ -1103,8 +1103,8 @@ func GetRemoveBotAtGroup() bool { // 获取ImageLimitB的值 func GetImageLimitB() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to ImageLimitB value.") @@ -1115,8 +1115,8 @@ func GetImageLimitB() int { // GetRecordSampleRate 返回 RecordSampleRate的值 func GetRecordSampleRate() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetRecordSampleRate value.") @@ -1128,8 +1128,8 @@ func GetRecordSampleRate() int { // GetRecordBitRate 返回 RecordBitRate func GetRecordBitRate() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetRecordBitRate value.") @@ -1141,8 +1141,8 @@ func GetRecordBitRate() int { // 获取NoWhiteResponse的值 func GetNoWhiteResponse() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to NoWhiteResponse value.") @@ -1153,8 +1153,8 @@ func GetNoWhiteResponse() string { // 获取GetSendError的值 func GetSendError() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetSendError value.") @@ -1165,8 +1165,8 @@ func GetSendError() bool { // 获取GetSaveError的值 func GetSaveError() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetSaveError value.") @@ -1177,8 +1177,8 @@ func GetSaveError() bool { // 获取GetAddAtGroup的值 func GetAddAtGroup() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetAddGroupAt value.") @@ -1189,8 +1189,8 @@ func GetAddAtGroup() bool { // 获取GetUrlPicTransfer的值 func GetUrlPicTransfer() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetUrlPicTransfer value.") @@ -1201,8 +1201,8 @@ func GetUrlPicTransfer() bool { // 获取GetLotusPassword的值 func GetLotusPassword() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetLotusPassword value.") @@ -1213,8 +1213,8 @@ func GetLotusPassword() string { // 获取GetWsServerPath的值 func GetWsServerPath() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetWsServerPath value.") @@ -1225,8 +1225,8 @@ func GetWsServerPath() string { // 获取GetIdmapPro的值 func GetIdmapPro() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetIdmapPro value.") @@ -1237,8 +1237,8 @@ func GetIdmapPro() bool { // 获取GetCardAndNick的值 func GetCardAndNick() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetCardAndNick value.") @@ -1249,8 +1249,8 @@ func GetCardAndNick() string { // 获取GetAutoBind的值 func GetAutoBind() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetAutoBind value.") @@ -1261,8 +1261,8 @@ func GetAutoBind() bool { // 获取GetCustomBotName的值 func GetCustomBotName() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetCustomBotName value.") @@ -1273,8 +1273,8 @@ func GetCustomBotName() string { // 获取send_delay的值 func GetSendDelay() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetSendDelay value.") @@ -1285,8 +1285,8 @@ func GetSendDelay() int { // 获取GetAtoPCount的值 func GetAtoPCount() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to AtoPCount value.") @@ -1297,8 +1297,8 @@ func GetAtoPCount() int { // 获取GetReconnecTimes的值 func GetReconnecTimes() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to ReconnecTimes value.") @@ -1309,8 +1309,8 @@ func GetReconnecTimes() int { // 获取GetHeartBeatInterval的值 func GetHeartBeatInterval() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to HeartBeatInterval value.") @@ -1321,8 +1321,8 @@ func GetHeartBeatInterval() int { // 获取LaunchReconectTimes func GetLaunchReconectTimes() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LaunchReconectTimes value.") @@ -1333,8 +1333,8 @@ func GetLaunchReconectTimes() int { // 获取GetUnlockPrefix func GetUnlockPrefix() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to UnlockPrefix value.") @@ -1345,8 +1345,8 @@ func GetUnlockPrefix() string { // 获取白名单例外群数组 func GetWhiteBypass() []int64 { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.WhiteBypass } @@ -1355,8 +1355,8 @@ func GetWhiteBypass() []int64 { // 获取GetTransferUrl的值 func GetTransferUrl() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetTransferUrl value.") @@ -1367,8 +1367,8 @@ func GetTransferUrl() bool { // 获取 HTTP 地址 func GetHttpAddress() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get HTTP address.") @@ -1379,8 +1379,8 @@ func GetHttpAddress() string { // 获取 HTTP 访问令牌 func GetHTTPAccessToken() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get HTTP access token.") @@ -1391,8 +1391,8 @@ func GetHTTPAccessToken() string { // 获取 HTTP 版本 func GetHttpVersion() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get HTTP version.") @@ -1403,8 +1403,8 @@ func GetHttpVersion() int { // 获取 HTTP 超时时间 func GetHttpTimeOut() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get HTTP timeout.") @@ -1415,8 +1415,8 @@ func GetHttpTimeOut() int { // 获取 POST URL 数组 func GetPostUrl() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get POST URL.") @@ -1427,8 +1427,8 @@ func GetPostUrl() []string { // 获取 POST 密钥数组 func GetPostSecret() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get POST secret.") @@ -1439,8 +1439,8 @@ func GetPostSecret() []string { // 获取 VisualPrefixsBypass func GetVisualPrefixsBypass() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to getVisualPrefixsBypass.") @@ -1451,8 +1451,8 @@ func GetVisualPrefixsBypass() []string { // 获取 POST 最大重试次数数组 func GetPostMaxRetries() []int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get POST max retries.") @@ -1463,8 +1463,8 @@ func GetPostMaxRetries() []int { // 获取 POST 重试间隔数组 func GetPostRetriesInterval() []int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get POST retries interval.") @@ -1475,8 +1475,8 @@ func GetPostRetriesInterval() []int { // 获取GetTransferUrl的值 func GetNativeOb11() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to NativeOb11 value.") @@ -1487,8 +1487,8 @@ func GetNativeOb11() bool { // 获取GetRamDomSeq的值 func GetRamDomSeq() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetRamDomSeq value.") @@ -1499,8 +1499,8 @@ func GetRamDomSeq() bool { // 获取GetUrlToQrimage的值 func GetUrlToQrimage() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetUrlToQrimage value.") @@ -1510,8 +1510,8 @@ func GetUrlToQrimage() bool { } func GetUseUin() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to UseUin value.") @@ -1522,8 +1522,8 @@ func GetUseUin() bool { // 获取GetQrSize的值 func GetQrSize() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to QrSize value.") @@ -1575,8 +1575,8 @@ func GetQrSize() int { // 获取GetWhiteBypassRevers的值 func GetWhiteBypassRevers() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetWhiteBypassRevers value.") @@ -1587,8 +1587,8 @@ func GetWhiteBypassRevers() bool { // 获取GetGuildUrlImageToBase64的值 func GetGuildUrlImageToBase64() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GuildUrlImageToBase64 value.") @@ -1599,8 +1599,8 @@ func GetGuildUrlImageToBase64() bool { // GetTencentBucketURL 获取 TencentBucketURL func GetTencentBucketURL() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get TencentBucketURL.") @@ -1621,8 +1621,8 @@ func GetTencentBucketURL() string { // GetTencentCosSecretid 获取 TencentCosSecretid func GetTencentCosSecretid() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get TencentCosSecretid.") @@ -1633,8 +1633,8 @@ func GetTencentCosSecretid() string { // GetTencentSecretKey 获取 TencentSecretKey func GetTencentSecretKey() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get TencentSecretKey.") @@ -1645,8 +1645,8 @@ func GetTencentSecretKey() string { // 获取GetTencentAudit的值 func GetTencentAudit() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to TencentAudit value.") @@ -1657,8 +1657,8 @@ func GetTencentAudit() bool { // 获取 Oss 模式 func GetOssType() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get ExtraPicAuditingType version.") @@ -1669,8 +1669,8 @@ func GetOssType() int { // 获取BaiduBOSBucketName func GetBaiduBOSBucketName() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get BaiduBOSBucketName.") @@ -1681,8 +1681,8 @@ func GetBaiduBOSBucketName() string { // 获取BaiduBCEAK func GetBaiduBCEAK() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get BaiduBCEAK.") @@ -1693,8 +1693,8 @@ func GetBaiduBCEAK() string { // 获取BaiduBCESK func GetBaiduBCESK() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get BaiduBCESK.") @@ -1705,8 +1705,8 @@ func GetBaiduBCESK() string { // 获取BaiduAudit func GetBaiduAudit() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get BaiduAudit.") @@ -1717,8 +1717,8 @@ func GetBaiduAudit() int { // 获取阿里云的oss地址 外网的 func GetAliyunEndpoint() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AliyunEndpoint.") @@ -1755,8 +1755,8 @@ func GetRegionID() string { // GetAliyunAccessKeyId 获取阿里云OSS的AccessKeyId func GetAliyunAccessKeyId() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AliyunAccessKeyId.") @@ -1767,8 +1767,8 @@ func GetAliyunAccessKeyId() string { // GetAliyunAccessKeySecret 获取阿里云OSS的AccessKeySecret func GetAliyunAccessKeySecret() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AliyunAccessKeySecret.") @@ -1779,8 +1779,8 @@ func GetAliyunAccessKeySecret() string { // GetAliyunBucketName 获取阿里云OSS的AliyunBucketName func GetAliyunBucketName() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AliyunBucketName.") @@ -1791,8 +1791,8 @@ func GetAliyunBucketName() string { // 获取GetAliyunAudit的值 func GetAliyunAudit() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to AliyunAudit value.") @@ -1803,8 +1803,8 @@ func GetAliyunAudit() bool { // 获取Alias的值 func GetAlias() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.Alias } @@ -1813,8 +1813,8 @@ func GetAlias() []string { // 获取SelfIntroduce的值 func GetSelfIntroduce() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.SelfIntroduce } @@ -1823,8 +1823,8 @@ func GetSelfIntroduce() []string { // 获取WhiteEnable的值 func GetWhiteEnable(index int) bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() // 检查instance或instance.Settings.WhiteEnable是否为nil if instance == nil || instance.Settings.WhiteEnable == nil { @@ -1845,8 +1845,8 @@ func GetWhiteEnable(index int) bool { // 获取IdentifyAppids的值 func GetIdentifyAppids() []int64 { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.IdentifyAppids } @@ -1855,8 +1855,8 @@ func GetIdentifyAppids() []int64 { // 获取 TransFormApiIds 的值 func GetTransFormApiIds() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to TransFormApiIds value.") @@ -1867,8 +1867,8 @@ func GetTransFormApiIds() bool { // 获取 CustomTemplateID 的值 func GetCustomTemplateID() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get CustomTemplateID.") @@ -1879,8 +1879,8 @@ func GetCustomTemplateID() string { // 获取 KeyBoardIDD 的值 func GetKeyBoardID() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get KeyBoardID.") @@ -1891,8 +1891,8 @@ func GetKeyBoardID() string { // 获取Uin int64 func GetUinint64() int64 { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.Uin } @@ -1901,8 +1901,8 @@ func GetUinint64() int64 { // 获取Uin String func GetUinStr() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return fmt.Sprintf("%d", instance.Settings.Uin) } @@ -1911,8 +1911,8 @@ func GetUinStr() string { // 获取 VV GetVwhitePrefixMode 的值 func GetVwhitePrefixMode() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to VwhitePrefixMode value.") @@ -1923,8 +1923,8 @@ func GetVwhitePrefixMode() bool { // 获取Enters的值 func GetEnters() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.Enters } @@ -1933,8 +1933,8 @@ func GetEnters() []string { // 获取EntersExcept func GetEntersExcept() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.EntersExcept } @@ -1943,8 +1943,8 @@ func GetEntersExcept() []string { // 获取 LinkPrefix func GetLinkPrefix() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LinkPrefix.") @@ -1955,8 +1955,8 @@ func GetLinkPrefix() string { // 获取 LinkBots 数组 func GetLinkBots() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LinkBots.") @@ -1967,8 +1967,8 @@ func GetLinkBots() []string { // 获取 LinkText func GetLinkText() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LinkText.") @@ -1979,8 +1979,8 @@ func GetLinkText() string { // 获取 LinkPic func GetLinkPic() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get LinkPic.") @@ -1991,8 +1991,8 @@ func GetLinkPic() string { // 获取 GetMusicPrefix func GetMusicPrefix() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get MusicPrefix.") @@ -2003,8 +2003,8 @@ func GetMusicPrefix() string { // 获取 GetDisableWebui 的值 func GetDisableWebui() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetDisableWebui value.") @@ -2015,8 +2015,8 @@ func GetDisableWebui() bool { // 获取 GetBotForumTitle func GetBotForumTitle() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get BotForumTitle.") @@ -2027,8 +2027,8 @@ func GetBotForumTitle() string { // 获取 GetGlobalInteractionToMessage 的值 func GetGlobalInteractionToMessage() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GlobalInteractionToMessage value.") @@ -2039,8 +2039,8 @@ func GetGlobalInteractionToMessage() bool { // 获取 AutoPutInteraction 的值 func GetAutoPutInteraction() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to AutoPutInteraction value.") @@ -2051,8 +2051,8 @@ func GetAutoPutInteraction() bool { // 获取 PutInteractionDelay 延迟 func GetPutInteractionDelay() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get PutInteractionDelay.") @@ -2063,8 +2063,8 @@ func GetPutInteractionDelay() int { // 获取Fix11300开关 func GetFix11300() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to Fix11300 value.") @@ -2075,8 +2075,8 @@ func GetFix11300() bool { // 获取LotusWithoutIdmaps开关 func GetLotusWithoutIdmaps() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LotusWithoutIdmaps value.") @@ -2087,8 +2087,8 @@ func GetLotusWithoutIdmaps() bool { // 获取GetGroupListAllGuilds开关 func GetGroupListAllGuilds() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetGroupListAllGuilds value.") @@ -2099,8 +2099,8 @@ func GetGroupListAllGuilds() bool { // 获取 GetGroupListGuilds 数量 func GetGetGroupListGuilds() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get GetGroupListGuilds.") @@ -2111,8 +2111,8 @@ func GetGetGroupListGuilds() string { // 获取GetGroupListReturnGuilds开关 func GetGroupListReturnGuilds() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GetGroupListReturnGuilds value.") @@ -2123,8 +2123,8 @@ func GetGroupListReturnGuilds() bool { // 获取 GetGroupListGuidsType 数量 func GetGroupListGuidsType() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get GetGroupListGuidsType.") @@ -2135,8 +2135,8 @@ func GetGroupListGuidsType() int { // 获取 GetGroupListDelay 数量 func GetGroupListDelay() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get GetGroupListDelay.") @@ -2147,8 +2147,8 @@ func GetGroupListDelay() int { // 获取GetGlobalServerTempQQguild开关 func GetGlobalServerTempQQguild() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GlobalServerTempQQguild value.") @@ -2159,8 +2159,8 @@ func GetGlobalServerTempQQguild() bool { // 获取ServerTempQQguild func GetServerTempQQguild() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to ServerTempQQguild value.") @@ -2171,8 +2171,8 @@ func GetServerTempQQguild() string { // 获取ServerTempQQguildPool func GetServerTempQQguildPool() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.ServerTempQQguildPool } @@ -2181,8 +2181,8 @@ func GetServerTempQQguildPool() []string { // 获取UploadPicV2Base64开关 func GetUploadPicV2Base64() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to UploadPicV2 value.") @@ -2193,8 +2193,8 @@ func GetUploadPicV2Base64() bool { // 获取 AutoWithdraw 数组 func GetAutoWithdraw() []string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AutoWithdraw.") @@ -2205,8 +2205,8 @@ func GetAutoWithdraw() []string { // 获取 GetAutoWithdrawTime 数量 func GetAutoWithdrawTime() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to get AutoWithdrawTime.") @@ -2217,8 +2217,8 @@ func GetAutoWithdrawTime() int { // 获取DefaultChangeWord func GetDefaultChangeWord() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.DefaultChangeWord } @@ -2227,8 +2227,8 @@ func GetDefaultChangeWord() string { // 获取敏感词替换状态 func GetEnableChangeWord() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to EnableChangeWord.") @@ -2239,8 +2239,8 @@ func GetEnableChangeWord() bool { // 获取GlobalGroupMsgRejectReciveEventToMessage状态 func GetGlobalGroupMsgRejectReciveEventToMessage() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to GlobalGroupMsgRejectReciveEventToMessage.") @@ -2251,8 +2251,8 @@ func GetGlobalGroupMsgRejectReciveEventToMessage() bool { // 获取GlobalGroupMsgRejectMessage func GetGlobalGroupMsgRejectMessage() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.GlobalGroupMsgRejectMessage } @@ -2261,8 +2261,8 @@ func GetGlobalGroupMsgRejectMessage() string { // 获取GlobalGroupMsgRejectMessage func GetGlobalGroupMsgReceiveMessage() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.GlobalGroupMsgReceiveMessage } @@ -2271,8 +2271,8 @@ func GetGlobalGroupMsgReceiveMessage() string { // 获取EntersAsBlock状态 func GetEntersAsBlock() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to EntersAsBlock.") @@ -2283,8 +2283,8 @@ func GetEntersAsBlock() bool { // 获取NativeMD状态 func GetNativeMD() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to NativeMD.") @@ -2295,8 +2295,8 @@ func GetNativeMD() bool { // 获取DowntimeMessage func GetDowntimeMessage() string { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance != nil { return instance.Settings.DowntimeMessage } @@ -2305,8 +2305,8 @@ func GetDowntimeMessage() string { // 获取GetAutoLink的值 func GetAutoLink() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to AutoLink value.") @@ -2317,8 +2317,8 @@ func GetAutoLink() bool { // 获取GetLinkLines的值 func GetLinkLines() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LinkLines value.") @@ -2330,8 +2330,8 @@ func GetLinkLines() int { // 获取GetLinkNum的值 func GetLinkNum() int { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LinkNum value.") @@ -2343,8 +2343,8 @@ func GetLinkNum() int { // 获取GetDoNotReplaceAppid的值 func GetDoNotReplaceAppid() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to DoNotReplaceAppid value.") @@ -2355,8 +2355,8 @@ func GetDoNotReplaceAppid() bool { // 获取GetMemoryMsgid的值 func GetMemoryMsgid() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to MemoryMsgid value.") @@ -2367,8 +2367,8 @@ func GetMemoryMsgid() bool { // 获取GetLotusGrpc的值 func GetLotusGrpc() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LotusGrpc value.") @@ -2379,8 +2379,8 @@ func GetLotusGrpc() bool { // 获取LotusWithoutUploadPic的值 func GetLotusWithoutUploadPic() bool { - mu.Lock() - defer mu.Unlock() + mu.RLock() + defer mu.RUnlock() if instance == nil { mylog.Println("Warning: instance is nil when trying to LotusWithoutUploadPic value.") @@ -2388,3 +2388,15 @@ func GetLotusWithoutUploadPic() bool { } return instance.Settings.LotusWithoutUploadPic } + +// 获取DisableErrorChan的值 +func GetDisableErrorChan() bool { + mu.RLock() + defer mu.RUnlock() + + if instance == nil { + mylog.Println("Warning: instance is nil when trying to DisableErrorChan value.") + return false + } + return instance.Settings.DisableErrorChan +} diff --git a/structs/structs.go b/structs/structs.go index 390ce9a5..b8b61106 100644 --- a/structs/structs.go +++ b/structs/structs.go @@ -120,9 +120,10 @@ type Settings struct { AutoPutInteraction bool `yaml:"auto_put_interaction"` PutInteractionDelay int `yaml:"put_interaction_delay"` //onebot修改 - TwoWayEcho bool `yaml:"twoway_echo"` - Array bool `yaml:"array"` - NativeOb11 bool `yaml:"native_ob11"` + TwoWayEcho bool `yaml:"twoway_echo"` + Array bool `yaml:"array"` + NativeOb11 bool `yaml:"native_ob11"` + DisableErrorChan bool `yaml:"disable_error_chan"` //url相关 VisibleIp bool `yaml:"visible_ip"` UrlToQrimage bool `yaml:"url_to_qrimage"` diff --git a/template/config_template.go b/template/config_template.go index 9c25bd11..f952046d 100644 --- a/template/config_template.go +++ b/template/config_template.go @@ -157,8 +157,9 @@ settings: #Onebot修改 twoway_echo : false #是否采用双向echo,根据机器人选择,獭獭\早苗 true 红色问答\椛椛 或者其他 请使用 false - array: false # 连接trss云崽请开启array + array: false #连接trss云崽请开启array,是否以segment形式上报信息. native_ob11 : false #如果你的机器人收到事件报错,请开启此选项增加兼容性 + disable_error_chan : false #禁用ws断开时候将信息放入补发频道,当信息非常多时可能导致冲垮应用端,可以设置本选项为true. #URL相关 visible_ip : false #转换url时,如果server_dir是ip true将以ip形式发出url 默认隐藏url 将server_dir配置为自己域名可以转换url diff --git a/wsclient/ws.go b/wsclient/ws.go index f635fd33..e0753463 100644 --- a/wsclient/ws.go +++ b/wsclient/ws.go @@ -45,7 +45,9 @@ func (client *WebSocketClient) SendMessage(message map[string]interface{}) error if err != nil { mylog.Println("Error sending message:", err) // 发送失败,将消息添加到切片 - client.sendFailures = append(client.sendFailures, message) + if !config.GetDisableErrorChan() { + client.sendFailures = append(client.sendFailures, message) + } return err }