Skip to content

Commit

Permalink
Test4 (#18)
Browse files Browse the repository at this point in the history
* Compiled main.go and pushed changes

* test

* 适配了频道私聊,用bolt数据库取代ini

* 适配了nonebot2

* add license

* add a lot

* trss support

* add action

* add action

* add action

* fixbug

* add wss

* bugfix

* fix action
  • Loading branch information
Hoshinonyaruko authored Oct 26, 2023
1 parent 0400d3b commit 3577012
Show file tree
Hide file tree
Showing 27 changed files with 926 additions and 31 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/cross_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Cross Compile Go Project

on:
pull_request:
types: [opened, synchronize]

jobs:
build:
name: Build on ${{ matrix.os }} for ${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
goarch: amd64
- os: linux
goarch: 386
- os: linux
goarch: arm
- os: linux
goarch: arm64
- os: darwin
goarch: amd64
- os: darwin
goarch: arm64
- os: windows
goarch: amd64
- os: windows
goarch: 386
- os: android
goarch: arm
- os: android
goarch: arm64
# ... Add other combinations as needed

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21.1' # Set to specific Go version.

- name: Setup Android NDK (only for Android builds)
if: matrix.os == 'android'
run: |
sudo apt-get install -y wget unzip
wget https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip || exit 1
unzip android-ndk-r21e-linux-x86_64.zip || exit 1
export ANDROID_NDK_HOME=$PWD/android-ndk-r21e
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
- name: Create output directory
run: mkdir -p output

- name: Compile Go for target
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ matrix.os == 'android' || matrix.goarch == 'arm' || matrix.goarch == 'arm64' ? '0' : '1' }}
run: |
go build -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
path: output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ idmap.db.lock
idmap.ini

# Go specific
go.mod
go.sum
*.exe

# Ignore channel_temp
Expand Down
18 changes: 18 additions & 0 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ func (p *Processor) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
Avatar: "",
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
groupMsg.Sender.Role = "owner"
} else {
groupMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "group_private")
Expand Down
35 changes: 35 additions & 0 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,24 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
onebotMsg.Sender.Role = "owner"
} else {
onebotMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
//通过echo始终得知真实的事件类型,来对应调用正确的api
Expand Down Expand Up @@ -217,6 +234,24 @@ func (p *Processor) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) e
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
groupMsg.Sender.Role = "owner"
} else {
groupMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "guild_private")
Expand Down
17 changes: 17 additions & 0 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,24 @@ func (p *Processor) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
Avatar: "",
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
groupMsg.Sender.Role = "owner"
} else {
groupMsg.Sender.Role = "member"
}
// 将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "group")
Expand Down
35 changes: 35 additions & 0 deletions Processor/ProcessGuildATMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,24 @@ func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
onebotMsg.Sender.Role = "owner"
} else {
onebotMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "guild")
Expand Down Expand Up @@ -143,6 +160,24 @@ func (p *Processor) ProcessGuildATMessage(data *dto.WSATMessageData) error {
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
groupMsg.Sender.Role = "owner"
} else {
groupMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "guild")
Expand Down
35 changes: 35 additions & 0 deletions Processor/ProcessGuildNormalMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,24 @@ func (p *Processor) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
onebotMsg.Sender.Role = "owner"
} else {
onebotMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "guild")
Expand Down Expand Up @@ -142,6 +159,24 @@ func (p *Processor) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
Avatar: data.Author.Avatar,
Echo: echostr,
}
// 获取MasterID数组
masterIDs := config.GetMasterID()

// 判断userid64是否在masterIDs数组里
isMaster := false
for _, id := range masterIDs {
if strconv.FormatInt(userid64, 10) == id {
isMaster = true
break
}
}

// 根据isMaster的值为groupMsg的Sender赋值role字段
if isMaster {
groupMsg.Sender.Role = "owner"
} else {
groupMsg.Sender.Role = "member"
}
//将当前s和appid和message进行映射
echo.AddMsgID(AppIDString, s, data.ID)
echo.AddMsgType(AppIDString, s, "guild")
Expand Down
1 change: 1 addition & 0 deletions Processor/Processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Sender struct {
Nickname string `json:"nickname"`
TinyID string `json:"tiny_id"`
UserID int64 `json:"user_id"`
Role string `json:"role,omitempty"`
}

// 频道信息事件
Expand Down
27 changes: 27 additions & 0 deletions botgo/examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module examples

go 1.17

require (
github.com/go-redis/redis/v8 v8.11.4
github.com/google/uuid v1.3.0
github.com/tencent-connect/botgo v0.0.0-00010101000000-000000000000
go.uber.org/zap v1.19.1
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-resty/resty/v2 v2.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/tidwall/gjson v1.9.3 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/tencent-connect/botgo => ../
Loading

0 comments on commit 3577012

Please sign in to comment.