Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta508 #509

Merged
merged 58 commits into from
Nov 23, 2024
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a6ebe57
beta447
Hoshinonyaruko Jun 29, 2024
1d63fae
beta448
Hoshinonyaruko Jul 1, 2024
cd34627
beta449
Hoshinonyaruko Jul 4, 2024
b790b29
beta450
Hoshinonyaruko Jul 4, 2024
7a9b56a
beta451
Hoshinonyaruko Jul 4, 2024
e17d0d4
beta452
Hoshinonyaruko Jul 4, 2024
1318175
beta453
Hoshinonyaruko Jul 4, 2024
b7f291c
beta454
Hoshinonyaruko Jul 4, 2024
f921895
beta455
Hoshinonyaruko Jul 9, 2024
24108c6
btea455
Hoshinonyaruko Jul 9, 2024
7cdc968
beta456
Hoshinonyaruko Jul 9, 2024
b5d784e
beta457
Hoshinonyaruko Jul 9, 2024
61e4001
beta458
Hoshinonyaruko Jul 9, 2024
6d4116a
beta460
Hoshinonyaruko Jul 9, 2024
2c1f1b7
beta460
Hoshinonyaruko Jul 11, 2024
5c312cd
beta461
Hoshinonyaruko Jul 12, 2024
58304eb
beta462
Hoshinonyaruko Jul 13, 2024
7e7c9f3
beta463
Hoshinonyaruko Jul 15, 2024
188f250
beta464
Hoshinonyaruko Jul 15, 2024
af0296d
beta465
Hoshinonyaruko Jul 18, 2024
500135c
beta467
Hoshinonyaruko Jul 21, 2024
c1a588c
beta468
Hoshinonyaruko Jul 21, 2024
1df8e15
beta469
Hoshinonyaruko Jul 21, 2024
f57ab7b
beta470
Hoshinonyaruko Jul 26, 2024
cd21ad9
beta471
Hoshinonyaruko Aug 1, 2024
6039272
beta472
Hoshinonyaruko Aug 1, 2024
c45b450
beta473
Hoshinonyaruko Aug 1, 2024
f89d6c5
beta473
Hoshinonyaruko Aug 3, 2024
b54fdee
beta475
Hoshinonyaruko Aug 5, 2024
a30a697
beta476
Hoshinonyaruko Aug 8, 2024
ab805cc
beta478
Hoshinonyaruko Aug 8, 2024
6debefd
beta479
Hoshinonyaruko Aug 17, 2024
9cc7e5d
beta479
Hoshinonyaruko Aug 17, 2024
c0fe93c
beta480
Hoshinonyaruko Aug 18, 2024
91cf223
beta481
Hoshinonyaruko Aug 18, 2024
a3aa6c1
beta482
Hoshinonyaruko Aug 18, 2024
0917e56
beta483
Hoshinonyaruko Aug 19, 2024
dd1f774
beta484
Hoshinonyaruko Aug 19, 2024
1c87d61
beta485
Hoshinonyaruko Aug 20, 2024
aac474a
beta486
Hoshinonyaruko Aug 20, 2024
2604eb7
beta486
Hoshinonyaruko Aug 20, 2024
76377be
beta487
Hoshinonyaruko Aug 20, 2024
cb095ec
beta487
Hoshinonyaruko Aug 20, 2024
34c92ae
beta489
Hoshinonyaruko Aug 21, 2024
288cf7a
beta490
Hoshinonyaruko Aug 22, 2024
d3a6eb8
beta491
Hoshinonyaruko Aug 22, 2024
b2de7c5
beta492
Hoshinonyaruko Oct 13, 2024
ec68fb1
beta492-1
Hoshinonyaruko Oct 13, 2024
f4d9229
beta494
Hoshinonyaruko Oct 13, 2024
def45ca
beta495
Hoshinonyaruko Oct 13, 2024
6eb3027
beta496
Hoshinonyaruko Oct 13, 2024
81f3aed
beta497
Hoshinonyaruko Oct 13, 2024
0b4001f
beta498
Hoshinonyaruko Oct 15, 2024
105c5c7
beta505
Hoshinonyaruko Nov 21, 2024
07fcc43
beta506
Hoshinonyaruko Nov 21, 2024
dbcfd58
beta507
Hoshinonyaruko Nov 22, 2024
754c36f
beta508
Hoshinonyaruko Nov 23, 2024
0fa988f
Merge branch 'main' into beta508
Hoshinonyaruko Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
beta479
  • Loading branch information
Hoshinonyaruko committed Aug 17, 2024
commit 6debefd052c60b3da6d4807f959b5e5aa85b807f
1 change: 1 addition & 0 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

if data.Author.ID == "" {
mylog.Printf("出现ID为空未知错误.%v\n", data)
return nil
}

//获取当前的s值 当前ws连接所收到的信息条数
1 change: 1 addition & 0 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {

if data.Author.ID == "" {
mylog.Printf("出现ID为空未知错误.%v\n", data)
return nil
}

if !config.GetStringOb11() {
16 changes: 15 additions & 1 deletion botgo/sessions/multi/multi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package multi

import (
"fmt"
"sync"
"time"

@@ -93,6 +94,19 @@ func (sm *ShardManager) newConnect(session dto.Session, shardID uint32) {
}
if err := wsClient.Listening(); err != nil {
log.Errorf("[ws/session] Listening error: %+v", err)
sm.SessionChans[shardID] <- session // Reconnect
currentSession := wsClient.Session()
// 对于不能够进行重连的session,需要清空 session id 与 seq
if manager.CanNotResume(err) {
currentSession.ID = ""
currentSession.LastSeq = 0
}
// 一些错误不能够鉴权,比如机器人被封禁,这里就直接退出了
if manager.CanNotIdentify(err) {
msg := fmt.Sprintf("can not identify because server return %+v, so process exit", err)
log.Errorf(msg)
panic(msg) // 当机器人被下架,或者封禁,将不能再连接,所以 panic
}
// 将 session 放到 session chan 中,用于启动新的连接,当前连接退出
sm.SessionChans[shardID] <- *currentSession // Reconnect
}
}
5 changes: 4 additions & 1 deletion handlers/send_private_msg_sse.go
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ func HandleSendPrivateMsgSSE(client callapi.Client, api openapi.OpenAPI, apiv2 o

// 输出反序列化后的对象,确认是否成功转换
fmt.Printf("Recovered InterfaceBody: %+v\n", messageBody)

// 使用 echo 获取消息ID
var messageID string
if config.GetLazyMessageId() {
@@ -135,7 +136,9 @@ func HandleSendPrivateMsgSSE(client callapi.Client, api openapi.OpenAPI, apiv2 o

// 获取并打印相关ID
relatedID := GetRelatedID(messageID)
fmt.Println("相关ID:", relatedID)

//fmt.Println("相关ID:", relatedID)

dtoSSE := generateMessageSSE(messageBody, messageID, relatedID)

mylog.Printf("私聊发信息sse:%v", dtoSSE)
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ import (
"syscall"
"time"

_ "net/http/pprof"

"github.com/fatih/color"
"github.com/fsnotify/fsnotify"
"github.com/hoshinonyaruko/gensokyo/Processor"
@@ -125,6 +127,7 @@ func main() {
//logger
logLevel := mylog.GetLogLevelFromConfig(config.GetLogLevel())
loggerAdapter := mylog.NewMyLogAdapter(logLevel, config.GetSaveLogs())
mylog.SetLogLevel(logLevel)
botgo.SetLogger(loggerAdapter)

if *m {
@@ -577,6 +580,14 @@ func main() {
}()
}

// 启动一个用于 pprof 的 HTTP 服务器
go func() {
log.Println("pprof server running on :6060")
if err := http.ListenAndServe("localhost:6060", nil); err != nil {
log.Fatalf("pprof server failed: %s", err)
}
}()

//杂七杂八的地方
if conf.Settings.MemoryMsgid {
echo.StartCleanupRoutine()
54 changes: 40 additions & 14 deletions mylog/mylog.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ const (
LogLevelError
)

var currentLevel = LogLevelInfo // 默认日志级别为 INFO

type Client struct {
conn *websocket.Conn
send chan EnhancedLogEntry
@@ -249,32 +251,56 @@ type EnhancedLogEntry struct {
// 日志频道,所有的 WebSocket 客户端都会在此监听日志事件
var logChannel = make(chan EnhancedLogEntry, 1000)

func SetLogLevel(level LogLevel) {
if level >= LogLevelDebug && level <= LogLevelError {
currentLevel = level
} else {
log.Printf("Invalid log level: %d", level)
}
}

func Println(v ...interface{}) {
log.Println(v...)
message := fmt.Sprint(v...)
emitLog("INFO", message)
LogToFile("INFO", message)
if currentLevel <= LogLevelInfo {
log.Println(v...)
message := fmt.Sprint(v...)
emitLog("INFO", message)
LogToFile("INFO", message)
}
}

func Printf(format string, v ...interface{}) {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("INFO", message)
LogToFile("INFO", message)
if currentLevel <= LogLevelInfo {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("INFO", message)
LogToFile("INFO", message)
}
}

func Warnf(format string, v ...interface{}) {
if currentLevel <= LogLevelWarn {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("WARN", message)
LogToFile("WARN", message)
}
}

func Errorf(format string, v ...interface{}) {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("ERROR", message)
LogToFile("ERROR", message)
if currentLevel <= LogLevelError {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("ERROR", message)
LogToFile("ERROR", message)
}
}

func Fatalf(format string, v ...interface{}) {
log.Printf(format, v...)
message := fmt.Sprintf(format, v...)
emitLog("Fatal", message)
LogToFile("Fatal", message)
emitLog("FATAL", message)
LogToFile("FATAL", message)
os.Exit(1) // Fatal logs usually terminate the program
}

func emitLog(level, message string) {