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 #30

Merged
merged 47 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 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
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
5 changes: 3 additions & 2 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hoshinonyaruko/gensokyo/echo"
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"
"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
)
Expand Down Expand Up @@ -103,13 +104,13 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//映射str的messageID到int
messageID64, err := idmap.StoreIDv2(data.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
messageID := int(messageID64)
Expand Down
11 changes: 6 additions & 5 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hoshinonyaruko/gensokyo/echo"
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"

"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
Expand Down Expand Up @@ -47,7 +48,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//将channelid写入数据库,可取出guild_id
ChannelID64, err := idmap.StoreIDv2(data.ChannelID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//转成int再互转
Expand Down Expand Up @@ -123,7 +124,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//OnebotChannelMessage
Expand Down Expand Up @@ -189,7 +190,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//将channelid写入bolt,可取出guild_id
ChannelID64, err := idmap.StoreIDv2(data.ChannelID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//转成int再互转 适用于群场景私聊
Expand All @@ -203,14 +204,14 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//userid := int(userid64)
//映射str的messageID到int
messageID64, err := idmap.StoreIDv2(data.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
messageID := int(messageID64)
Expand Down
6 changes: 3 additions & 3 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package Processor

import (
"fmt"
"log"
"strconv"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
"github.com/hoshinonyaruko/gensokyo/echo"
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"

"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
Expand Down Expand Up @@ -39,14 +39,14 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
// 映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}

//映射str的messageID到int
messageID64, err := idmap.StoreIDv2(data.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
messageID := int(messageID64)
Expand Down
10 changes: 5 additions & 5 deletions Processor/ProcessGuildATMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package Processor

import (
"fmt"
"log"
"strconv"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
"github.com/hoshinonyaruko/gensokyo/echo"
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"

"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
Expand All @@ -35,7 +35,7 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
// 如果在Array模式下, 则处理Message为Segment格式
Expand Down Expand Up @@ -109,7 +109,7 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//将channelid写入ini,可取出guild_id
ChannelID64, err := idmap.StoreIDv2(data.ChannelID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//转成int再互转
Expand All @@ -123,14 +123,14 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//userid := int(userid64)
//映射str的messageID到int
messageID64, err := idmap.StoreIDv2(data.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
messageID := int(messageID64)
Expand Down
10 changes: 5 additions & 5 deletions Processor/ProcessGuildNormalMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package Processor

import (
"fmt"
"log"
"strconv"
"time"

"github.com/hoshinonyaruko/gensokyo/config"
"github.com/hoshinonyaruko/gensokyo/echo"
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"
"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
)
Expand All @@ -34,7 +34,7 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
// 如果在Array模式下, 则处理Message为Segment格式
Expand Down Expand Up @@ -108,7 +108,7 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
//将channelid写入ini,可取出guild_id
ChannelID64, err := idmap.StoreIDv2(data.ChannelID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//转成int再互转
Expand All @@ -122,14 +122,14 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
//userid := int(userid64)
//映射str的messageID到int
messageID64, err := idmap.StoreIDv2(data.ID)
if err != nil {
log.Printf("Error storing ID: %v", err)
mylog.Printf("Error storing ID: %v", err)
return nil
}
messageID := int(messageID64)
Expand Down
7 changes: 4 additions & 3 deletions Processor/Processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/hoshinonyaruko/gensokyo/callapi"
"github.com/hoshinonyaruko/gensokyo/config"
"github.com/hoshinonyaruko/gensokyo/mylog"
"github.com/hoshinonyaruko/gensokyo/wsclient"
"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/openapi"
Expand Down Expand Up @@ -140,7 +141,7 @@ func (p *Processors) ProcessInlineSearch(data *dto.WSInteractionData) error {
// context.Background(), dm, toCreate,
// )
// if err != nil {
// log.Println("Error sending default reply:", err)
// mylog.Println("Error sending default reply:", err)
// return nil
// }

Expand All @@ -157,15 +158,15 @@ func PrintStructWithFieldNames(v interface{}) {

// 确保我们传入的是一个结构体
if typ.Kind() != reflect.Struct {
fmt.Println("Input is not a struct")
mylog.Println("Input is not a struct")
return
}

// 迭代所有的字段并打印字段名和值
for i := 0; i < typ.NumField(); i++ {
field := typ.Field(i)
value := val.Field(i)
fmt.Printf("%s: %v\n", field.Name, value.Interface())
mylog.Printf("%s: %v\n", field.Name, value.Interface())
}
}

Expand Down
2 changes: 1 addition & 1 deletion botgo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {

// 监听哪类事件就需要实现哪类的 handler,定义:websocket/event_handler.go
var atMessage websocket.ATMessageEventHandler = func(event *dto.WSPayload, data *dto.WSATMessageData) error {
fmt.Println(event, data)
log.Println(event, data)
return nil
}
intent := websocket.RegisterHandlers(atMessage)
Expand Down
4 changes: 2 additions & 2 deletions botgo/event/register_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package event

import (
"fmt"
"log"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -22,7 +22,7 @@ func TestRegisterHandlers(t *testing.T) {
t.Run(
"test intent", func(t *testing.T) {
i := RegisterHandlers(guild, message, audio)
fmt.Println(i)
log.Println(i)
assert.Equal(t, dto.IntentGuildMessages, i&dto.IntentGuildMessages)
assert.Equal(t, dto.IntentGuilds, i&dto.IntentGuilds)
assert.Equal(t, dto.IntentAudio, i&dto.IntentAudio)
Expand Down
4 changes: 2 additions & 2 deletions botgo/examples/apitest/message_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apitest

import (
"fmt"
"log"
"testing"

"github.com/tencent-connect/botgo/dto/keyboard"
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestMessage(t *testing.T) {
}

message, err := api.Message(ctx, testChannelID, index[0])
fmt.Println(message)
log.Println(message)
},
)
}
Expand Down
4 changes: 2 additions & 2 deletions botgo/examples/receive-and-send/forum.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"fmt"
"log"

"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/event"
Expand All @@ -10,7 +10,7 @@ import (
// ThreadEventHandler 论坛主贴事件
func ThreadEventHandler() event.ThreadEventHandler {
return func(event *dto.WSPayload, data *dto.WSThreadData) error {
fmt.Println(event, data)
log.Println(event, data)
return nil
}
}
12 changes: 6 additions & 6 deletions botgo/examples/receive-and-send/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,47 +108,47 @@ func ATMessageEventHandler() event.ATMessageEventHandler {
// GuildEventHandler 处理频道事件
func GuildEventHandler() event.GuildEventHandler {
return func(event *dto.WSPayload, data *dto.WSGuildData) error {
fmt.Println(data)
log.Println(data)
return nil
}
}

// ChannelEventHandler 处理子频道事件
func ChannelEventHandler() event.ChannelEventHandler {
return func(event *dto.WSPayload, data *dto.WSChannelData) error {
fmt.Println(data)
log.Println(data)
return nil
}
}

// MemberEventHandler 处理成员变更事件
func MemberEventHandler() event.GuildMemberEventHandler {
return func(event *dto.WSPayload, data *dto.WSGuildMemberData) error {
fmt.Println(data)
log.Println(data)
return nil
}
}

// DirectMessageHandler 处理私信事件
func DirectMessageHandler() event.DirectMessageEventHandler {
return func(event *dto.WSPayload, data *dto.WSDirectMessageData) error {
fmt.Println(data)
log.Println(data)
return nil
}
}

// CreateMessageHandler 处理消息事件
func CreateMessageHandler() event.MessageEventHandler {
return func(event *dto.WSPayload, data *dto.WSMessageData) error {
fmt.Println(data)
log.Println(data)
return nil
}
}

// InteractionHandler 处理内联交互事件
func InteractionHandler() event.InteractionEventHandler {
return func(event *dto.WSPayload, data *dto.WSInteractionData) error {
fmt.Println(data)
log.Println(data)
return processor.ProcessInlineSearch(data)
}
}
Expand Down
Loading
Loading