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

Test4 #55

Merged
merged 108 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
fad0d50
Compiled main.go and pushed changes
Hoshinonyaruko Oct 23, 2023
fda2572
test
Hoshinonyaruko Oct 23, 2023
34cfac1
适配了频道私聊,用bolt数据库取代ini
Hoshinonyaruko Oct 23, 2023
7fc1f10
适配了nonebot2
Hoshinonyaruko Oct 24, 2023
28f9a73
Merge branch 'main' of https://github.com/Hoshinonyaruko/Gensokyo
Hoshinonyaruko Oct 24, 2023
9fadda4
适配私域
Hoshinonyaruko Oct 24, 2023
1336c6a
add license
Hoshinonyaruko Oct 24, 2023
b094949
add a lot
Hoshinonyaruko Oct 25, 2023
f4787f5
Resolved merge conflicts
Hoshinonyaruko Oct 25, 2023
86698c6
trss support
Hoshinonyaruko Oct 26, 2023
045f3e9
fix
Hoshinonyaruko Oct 26, 2023
618561c
add action
Hoshinonyaruko Oct 26, 2023
7e803aa
add action
Hoshinonyaruko Oct 26, 2023
ece4cef
add action
Hoshinonyaruko Oct 26, 2023
f864a50
fixbug
Hoshinonyaruko Oct 26, 2023
4564731
add wss
Hoshinonyaruko Oct 26, 2023
070e4df
merge
Hoshinonyaruko Oct 26, 2023
84e8fe9
bugfix
Hoshinonyaruko Oct 26, 2023
0e4fd50
fix action
Hoshinonyaruko Oct 26, 2023
fe2234a
fix action again
Hoshinonyaruko Oct 26, 2023
cf67a11
fix action againnn
Hoshinonyaruko Oct 26, 2023
0875837
fa
Hoshinonyaruko Oct 26, 2023
3a3c33f
fix
Hoshinonyaruko Oct 26, 2023
8789fa8
add a lot
Hoshinonyaruko Oct 27, 2023
7943466
add ws server token
Hoshinonyaruko Oct 28, 2023
4660983
merge
Hoshinonyaruko Oct 28, 2023
2a1026a
bugifx
Hoshinonyaruko Oct 28, 2023
4186970
fix
Hoshinonyaruko Oct 28, 2023
2f26828
fixat
Hoshinonyaruko Oct 28, 2023
007e1af
bugfix
Hoshinonyaruko Oct 28, 2023
c41fd77
bugfix
Hoshinonyaruko Oct 28, 2023
d8354b7
test
Hoshinonyaruko Oct 28, 2023
6e3c63c
test
Hoshinonyaruko Oct 28, 2023
f08d9d7
test2
Hoshinonyaruko Oct 28, 2023
4dd6e15
add url service
Hoshinonyaruko Oct 31, 2023
1f8c174
add url service
Hoshinonyaruko Oct 31, 2023
240f569
add url service
Hoshinonyaruko Oct 31, 2023
b191cb7
bugfix
Hoshinonyaruko Oct 31, 2023
42daab3
merge
Hoshinonyaruko Oct 31, 2023
8fec03f
fix
Hoshinonyaruko Oct 31, 2023
cca528b
fix
Hoshinonyaruko Oct 31, 2023
463a182
fix
Hoshinonyaruko Oct 31, 2023
e9187a1
bug fix
Hoshinonyaruko Nov 1, 2023
5ba2815
fix
Hoshinonyaruko Nov 1, 2023
c16e1af
fix
Hoshinonyaruko Nov 1, 2023
ec7863d
test
Hoshinonyaruko Nov 2, 2023
e8a7e73
ok
Hoshinonyaruko Nov 2, 2023
122d17d
add webui
Hoshinonyaruko Nov 2, 2023
4e9c209
merge
Hoshinonyaruko Nov 2, 2023
b502d61
add image_compress
Hoshinonyaruko Nov 3, 2023
3519e3e
merge
Hoshinonyaruko Nov 3, 2023
530ff96
bug fix
Hoshinonyaruko Nov 3, 2023
155a701
fix cq code
Hoshinonyaruko Nov 3, 2023
2f5ee4a
fixbug
Hoshinonyaruko Nov 3, 2023
afa03e3
bugfix
Hoshinonyaruko Nov 3, 2023
fdd1a73
merge
Hoshinonyaruko Nov 3, 2023
fe39cd2
bugfix
Hoshinonyaruko Nov 3, 2023
be08cbe
bugfix
Hoshinonyaruko Nov 3, 2023
931dfef
merge
Hoshinonyaruko Nov 3, 2023
73819c8
bugfix
Hoshinonyaruko Nov 3, 2023
b27f062
bugfix
Hoshinonyaruko Nov 3, 2023
1a94197
bugfix
Hoshinonyaruko Nov 3, 2023
745b28e
bugfix
Hoshinonyaruko Nov 3, 2023
1212c9a
bugfix
Hoshinonyaruko Nov 4, 2023
44d8669
bugfix
Hoshinonyaruko Nov 4, 2023
564aba5
add new feature
Hoshinonyaruko Nov 5, 2023
d7345c1
bugfix
Hoshinonyaruko Nov 5, 2023
472a224
bugfix
Hoshinonyaruko Nov 5, 2023
e22b58b
bugfix
Hoshinonyaruko Nov 5, 2023
22cb473
bugfix
Hoshinonyaruko Nov 5, 2023
e563929
bugfix
Hoshinonyaruko Nov 5, 2023
829b5d7
merge
Hoshinonyaruko Nov 5, 2023
b496ac1
bugfix
Hoshinonyaruko Nov 5, 2023
13e7700
bugfix
Hoshinonyaruko Nov 5, 2023
eb7e630
bugfix
Hoshinonyaruko Nov 5, 2023
32d490f
test
Hoshinonyaruko Nov 5, 2023
9815e3a
test
Hoshinonyaruko Nov 5, 2023
7747de6
test
Hoshinonyaruko Nov 5, 2023
fe2e4be
test
Hoshinonyaruko Nov 5, 2023
ec9e797
test
Hoshinonyaruko Nov 5, 2023
3548108
test
Hoshinonyaruko Nov 5, 2023
1e50a7c
test
Hoshinonyaruko Nov 5, 2023
812e6ea
test
Hoshinonyaruko Nov 5, 2023
76363a6
test
Hoshinonyaruko Nov 5, 2023
d8b05cd
test
Hoshinonyaruko Nov 5, 2023
c2e2b20
test
Hoshinonyaruko Nov 5, 2023
cefac16
test
Hoshinonyaruko Nov 5, 2023
273db15
test
Hoshinonyaruko Nov 5, 2023
5379f7d
test
Hoshinonyaruko Nov 5, 2023
56e2429
test
Hoshinonyaruko Nov 5, 2023
4466f30
test
Hoshinonyaruko Nov 6, 2023
a32a124
test
Hoshinonyaruko Nov 6, 2023
246d9c4
test
Hoshinonyaruko Nov 6, 2023
c91d9e2
test
Hoshinonyaruko Nov 6, 2023
6007979
bugfix
Hoshinonyaruko Nov 6, 2023
af64c33
bugfix
Hoshinonyaruko Nov 6, 2023
f5cfda3
Remove dist directory from tracking
Hoshinonyaruko Nov 6, 2023
53b6e5d
test
Hoshinonyaruko Nov 6, 2023
3991193
test
Hoshinonyaruko Nov 7, 2023
7af6759
bugfix2
Hoshinonyaruko Nov 7, 2023
fdec4ca
bugfix3
Hoshinonyaruko Nov 7, 2023
849c638
bugfix4
Hoshinonyaruko Nov 7, 2023
f268f3d
bugfix5
Hoshinonyaruko Nov 7, 2023
7ada595
bugfix5
Hoshinonyaruko Nov 8, 2023
76376a0
bugfix6
Hoshinonyaruko Nov 8, 2023
8332932
bugfix7
Hoshinonyaruko Nov 8, 2023
ac05d43
bugfix8
Hoshinonyaruko Nov 8, 2023
47b672c
bugfix9
Hoshinonyaruko Nov 8, 2023
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
add a lot
Hoshinonyaruko committed Oct 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8789fa88761cb75d95409963d760884a9d741ace
40 changes: 31 additions & 9 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
@@ -16,7 +17,7 @@ import (
)

// ProcessC2CMessage 处理C2C消息 群私聊
func (p *Processor) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
// 打印data结构体
PrintStructWithFieldNames(data)

@@ -89,15 +90,26 @@ func (p *Processor) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

// Convert OnebotGroupMessage to map and send
privateMsgMap := structToMap(privateMsg)
err = p.Wsclient.SendMessage(privateMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(privateMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending private message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
} else {
//将私聊信息转化为群信息(特殊需求情况下)

//转换at
messageText := handlers.RevertTransformedText(data.Content)
messageText := handlers.RevertTransformedText(data)
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
@@ -165,11 +177,21 @@ func (p *Processor) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

// Convert OnebotGroupMessage to map and send
groupMsgMap := structToMap(groupMsg)
err = p.Wsclient.SendMessage(groupMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(groupMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending group message via wsclient: %v", err))
}
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
log.Println("Encountered errors while sending to wsclients:", strings.Join(errors, "; "))
}
}
return nil
}
58 changes: 45 additions & 13 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
@@ -17,7 +18,7 @@ import (
)

// ProcessChannelDirectMessage 处理频道私信消息 这里我们是被动收到
func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) error {
func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) error {
// 打印data结构体
//PrintStructWithFieldNames(data)

@@ -93,9 +94,20 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e

// Convert OnebotGroupMessage to map and send
privateMsgMap := structToMap(privateMsg)
err = p.Wsclient.SendMessage(privateMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(privateMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending private message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
} else {
if !p.Settings.GlobalChannelToGroup {
@@ -109,7 +121,7 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e
//获取s
s := client.GetGlobalS()
//转换at
messageText := handlers.RevertTransformedText(data.Content)
messageText := handlers.RevertTransformedText(data)
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
@@ -175,18 +187,27 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e

// 将 onebotMsg 结构体转换为 map[string]interface{}
msgMap := structToMap(onebotMsg)
var errors []string

// 使用 wsclient 发送消息
err = p.Wsclient.SendMessage(msgMap)
if err != nil {
return fmt.Errorf("error sending message via wsclient: %v", err)
for _, client := range p.Wsclient {
err = client.SendMessage(msgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
} else {
//将频道信息转化为群信息(特殊需求情况下)
//将channelid写入ini,可取出guild_id
idmap.WriteConfigv2(data.ChannelID, "guild_id", data.GuildID)
//转换at
messageText := handlers.RevertTransformedText(data.Content)
messageText := handlers.RevertTransformedText(data)
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
@@ -266,9 +287,20 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e

// Convert OnebotGroupMessage to map and send
groupMsgMap := structToMap(groupMsg)
err = p.Wsclient.SendMessage(groupMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(groupMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending group message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
}

21 changes: 16 additions & 5 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
@@ -17,14 +18,14 @@ import (
)

// ProcessGroupMessage 处理群组消息
func (p *Processor) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
// 获取s
s := client.GetGlobalS()

idmap.WriteConfigv2(data.ChannelID, "guild_id", data.GuildID)

// 转换at
messageText := handlers.RevertTransformedText(data.Content)
messageText := handlers.RevertTransformedText(data)

// 转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
@@ -107,10 +108,20 @@ func (p *Processor) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {

// Convert OnebotGroupMessage to map and send
groupMsgMap := structToMap(groupMsg)
err = p.Wsclient.SendMessage(groupMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(groupMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending group message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
return nil
}
43 changes: 32 additions & 11 deletions Processor/ProcessGuildATMessage.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
@@ -17,7 +18,7 @@ import (
)

// ProcessGuildATMessage 处理消息,执行逻辑并可能使用 api 发送响应
func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {
func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
if !p.Settings.GlobalChannelToGroup {
// 将时间字符串转换为时间戳
t, err := time.Parse(time.RFC3339, string(data.Timestamp))
@@ -27,7 +28,7 @@ func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//获取s
s := client.GetGlobalS()
//转换at
messageText := handlers.RevertTransformedText(data.Content)
messageText := handlers.RevertTransformedText(data)
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
@@ -98,21 +99,30 @@ func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {
// 将 onebotMsg 结构体转换为 map[string]interface{}
msgMap := structToMap(onebotMsg)

// 使用 wsclient 发送消息
err = p.Wsclient.SendMessage(msgMap)
if err != nil {
return fmt.Errorf("error sending message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(msgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}
} else {
// GlobalChannelToGroup为true时的处理逻辑
//将频道转化为一个群
//获取s
s := client.GetGlobalS()
//将channelid写入ini,可取出guild_id todo 比ini更好的储存方式
idmap.WriteConfigv2(data.ChannelID, "guild_id", data.GuildID)
//转换at
messageText := handlers.RevertTransformedText(data.Content)
//转换at和图片
messageText := handlers.RevertTransformedText(data)
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
@@ -192,9 +202,20 @@ func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {

// Convert OnebotGroupMessage to map and send
groupMsgMap := structToMap(groupMsg)
err = p.Wsclient.SendMessage(groupMsgMap)
if err != nil {
return fmt.Errorf("error sending group message via wsclient: %v", err)
var errors []string

for _, client := range p.Wsclient {
err = client.SendMessage(groupMsgMap)
if err != nil {
// 记录错误信息,但不立即返回
errors = append(errors, fmt.Sprintf("error sending group message via wsclient: %v", err))
}
}

// 在循环结束后处理记录的错误
if len(errors) > 0 {
// 使用strings.Join合并所有的错误信息
return fmt.Errorf(strings.Join(errors, "; "))
}

}
Loading