mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
chore(lint): 改进代码样式 (#1143)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
e292b69ee5
commit
6c6699a5d6
@ -3,13 +3,14 @@ package minecraftobserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zbpCtxExt "github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -240,7 +241,7 @@ func singleServerScan(oldSubStatus *serverStatus) (changed bool, notifyMsg messa
|
||||
err = nil
|
||||
// 计数器没有超限,增加计数器并跳过
|
||||
if cnt, ts := addPingServerUnreachableCounter(oldSubStatus.ServerAddr, time.Now()); cnt < pingServerUnreachableCounterThreshold &&
|
||||
time.Now().Sub(ts) < pingServerUnreachableCounterTimeThreshold {
|
||||
time.Since(ts) < pingServerUnreachableCounterTimeThreshold {
|
||||
// logrus.Warnln(logPrefix+"server ", oldSubStatus.ServerAddr, " unreachable, counter: ", cnt, " ts:", ts)
|
||||
return
|
||||
}
|
||||
|
||||
@ -4,11 +4,12 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tnze/go-mc/chat"
|
||||
"github.com/google/uuid"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ====================
|
||||
@ -237,13 +238,13 @@ func formatSubStatusChangeText(oldStatus, newStatus *serverStatus) string {
|
||||
// 状态由不可达变为可达,反之
|
||||
if oldStatus.PingDelay == pingDelayUnreachable && newStatus.PingDelay != pingDelayUnreachable {
|
||||
msgBuilder.WriteString("\n-----[Ping延迟]-----\n")
|
||||
msgBuilder.WriteString(fmt.Sprintf("[旧]\n超时\n"))
|
||||
msgBuilder.WriteString("[旧]\n超时\n")
|
||||
msgBuilder.WriteString(fmt.Sprintf("[新]\n%v毫秒\n", newStatus.PingDelay))
|
||||
}
|
||||
if oldStatus.PingDelay != pingDelayUnreachable && newStatus.PingDelay == pingDelayUnreachable {
|
||||
msgBuilder.WriteString("\n-----[Ping延迟]-----\n")
|
||||
msgBuilder.WriteString(fmt.Sprintf("[旧]\n%v毫秒\n", oldStatus.PingDelay))
|
||||
msgBuilder.WriteString(fmt.Sprintf("[新]\n超时\n"))
|
||||
msgBuilder.WriteString("[新]\n超时\n")
|
||||
}
|
||||
return msgBuilder.String()
|
||||
}
|
||||
|
||||
@ -2,9 +2,10 @@ package minecraftobserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/Tnze/go-mc/bot"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -2,13 +2,14 @@ package minecraftobserver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/jinzhu/gorm"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -60,8 +61,7 @@ var (
|
||||
dbInstance *db
|
||||
// 开启并检查数据库链接
|
||||
getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
var err error
|
||||
err = initializeDB(engine.DataFolder() + dbPath)
|
||||
var err error = initializeDB(engine.DataFolder() + dbPath)
|
||||
if err != nil {
|
||||
// logrus.Errorln(logPrefix+"initializeDB ERROR: ", err)
|
||||
ctx.SendChain(message.Text("[mc-ob] ERROR: ", err))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user