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

Beta391 #391

Merged
merged 41 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ca914e2
beta338
Hoshinonyaruko Mar 4, 2024
62e6985
beta319
Hoshinonyaruko Mar 5, 2024
8c8792c
beta340
Hoshinonyaruko Mar 7, 2024
5fe4fae
beta341
Hoshinonyaruko Mar 17, 2024
bdb5874
actionfix
Hoshinonyaruko Mar 17, 2024
b2f53f5
beta342
Hoshinonyaruko Mar 17, 2024
666ea3a
beta342
Hoshinonyaruko Mar 17, 2024
a5e3867
beta342
Hoshinonyaruko Mar 17, 2024
a217d2f
beta344
Hoshinonyaruko Mar 18, 2024
6df84f8
beta345
Hoshinonyaruko Mar 22, 2024
2aac729
beta346
Hoshinonyaruko Mar 22, 2024
7546989
beta347
Hoshinonyaruko Mar 23, 2024
3ea73d5
beta348
Hoshinonyaruko Mar 23, 2024
ab6c474
beta349
Hoshinonyaruko Mar 24, 2024
8a83045
beta350
Hoshinonyaruko Mar 24, 2024
0eb64d6
beta351
Hoshinonyaruko Mar 24, 2024
123be98
beta352
Hoshinonyaruko Mar 24, 2024
33611e1
beta353
Hoshinonyaruko Mar 25, 2024
3d9d2b6
beta354
Hoshinonyaruko Mar 25, 2024
b3a8b7f
beta355
Hoshinonyaruko Mar 25, 2024
0adfd26
beta356
Hoshinonyaruko Mar 31, 2024
afdf12e
beta357
Hoshinonyaruko Apr 7, 2024
78ab737
beta358
Hoshinonyaruko Apr 8, 2024
1af000b
beta359
Hoshinonyaruko Apr 12, 2024
40f832c
beta360
Hoshinonyaruko Apr 15, 2024
a9afc91
beta361
Hoshinonyaruko Apr 16, 2024
16cef02
beta362
Hoshinonyaruko Apr 16, 2024
48aa4c7
beta363
Hoshinonyaruko Apr 17, 2024
f30fe85
beta365
Hoshinonyaruko Apr 18, 2024
a6c503d
beta366
Hoshinonyaruko Apr 19, 2024
4976b9a
beta367
Hoshinonyaruko Apr 22, 2024
f4d67a0
beta368
Hoshinonyaruko Apr 22, 2024
8dec46c
beta382
Hoshinonyaruko Apr 25, 2024
604e53a
bet383
Hoshinonyaruko Apr 27, 2024
399d57c
beta383
Hoshinonyaruko Apr 27, 2024
8b2177a
beta385
Hoshinonyaruko Apr 27, 2024
dd4840f
beta386
Hoshinonyaruko Apr 27, 2024
27c9da5
beta387
Hoshinonyaruko May 2, 2024
8b30bd5
beta389
Hoshinonyaruko May 3, 2024
223783d
beta390
Hoshinonyaruko May 4, 2024
fa5b88f
beta391
Hoshinonyaruko May 4, 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
19 changes: 17 additions & 2 deletions .github/workflows/cross_compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,24 @@ jobs:
CGO_ENABLED: 0
run: |
if [ "$GOOS" = "windows" ]; then
go build -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}.exe
go build -ldflags="-s -w" -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}.exe
else
go build -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
go build -ldflags="-s -w" -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
fi

- name: Compress executable files with UPX (except for gensokyo-android-arm64)
run: |
sudo apt-get update
sudo apt-get install -y upx
if [[ "${{ matrix.os }}" == *"windows"* ]]; then
FILENAME="output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}.exe"
else
FILENAME="output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}"
fi
if [[ "${{ matrix.os }}" == "android" && "${{ matrix.goarch }}" == "arm64" ]]; then
echo "Skipping UPX compression for $FILENAME"
else
upx --best --lzma "$FILENAME"
fi

- name: Upload artifacts
Expand Down
52 changes: 47 additions & 5 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hoshinonyaruko/gensokyo/handlers"
"github.com/hoshinonyaruko/gensokyo/idmap"
"github.com/hoshinonyaruko/gensokyo/mylog"
"github.com/hoshinonyaruko/gensokyo/structs"
"github.com/tencent-connect/botgo/dto"
"github.com/tencent-connect/botgo/websocket/client"
)
Expand All @@ -34,7 +35,10 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

//转换appidstring
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
echostr := AppIDString + "_" + strconv.FormatInt(s, 10)
// 获取当前时间的13位毫秒级时间戳
currentTimeMillis := time.Now().UnixNano() / 1e6
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)
var userid64 int64
var err error
if config.GetIdmapPro() {
Expand Down Expand Up @@ -93,13 +97,21 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
} else {
IsBindedUserId = idmap.CheckValuev2(userid64)
}

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}

privateMsg := OnebotPrivateMessage{
RawMessage: messageText,
Message: segmentedMessages,
MessageID: messageID,
MessageType: "private",
PostType: "message",
SelfID: int64(p.Settings.AppID),
SelfID: selfid64,
UserID: userid64,
Sender: PrivateSender{
Nickname: "", //这个不支持,但加机器人好友,会收到一个事件,可以对应储存获取,用idmaps可以做到.
Expand Down Expand Up @@ -143,13 +155,24 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
privateMsgMap := structToMap(privateMsg)
//上报信息到onebotv11应用端(正反ws)
p.BroadcastMessageToAll(privateMsgMap)
//组合FriendData
struserid := strconv.FormatInt(userid64, 10)
userdata := structs.FriendData{
Nickname: "",
Remark: "",
UserID: struserid,
}
//缓存私信好友列表
idmap.StoreUserInfo(data.Author.ID, userdata)
} else {
//将私聊信息转化为群信息(特殊需求情况下)

//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
echostr := AppIDString + "_" + strconv.FormatInt(s, 10)
// 获取当前时间的13位毫秒级时间戳
currentTimeMillis := time.Now().UnixNano() / 1e6
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)
//把userid作为群号
//映射str的userid到int
var userid64 int64
Expand Down Expand Up @@ -190,14 +213,22 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
messageID := int(messageID64)
//todo 判断array模式 然后对Message处理成array格式
IsBindedUserId := idmap.CheckValue(data.Author.ID, userid64)

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}

groupMsg := OnebotGroupMessage{
RawMessage: messageText,
Message: messageText,
MessageID: messageID,
GroupID: userid64,
MessageType: "group",
PostType: "message",
SelfID: int64(p.Settings.AppID),
SelfID: selfid64,
UserID: userid64,
Sender: Sender{
UserID: userid64,
Expand Down Expand Up @@ -262,6 +293,17 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
groupMsgMap := structToMap(groupMsg)
//上报信息到onebotv11应用端(正反ws)
p.BroadcastMessageToAll(groupMsgMap)

//组合FriendData
struserid := strconv.FormatInt(userid64, 10)
userdata := structs.FriendData{
Nickname: "",
Remark: "",
UserID: struserid,
}
//缓存私信好友列表
idmap.StoreUserInfo(data.Author.ID, userdata)
}

return nil
}
50 changes: 39 additions & 11 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)

//转换appidstring
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
echostr := AppIDString + "_" + strconv.FormatInt(s, 10)
// 获取当前时间的13位毫秒级时间戳
currentTimeMillis := time.Now().UnixNano() / 1e6
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)

var userid64 int64
var ChannelID64 int64
Expand Down Expand Up @@ -117,13 +120,20 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
IsBindedUserId = idmap.CheckValuev2(userid64)
}

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}

privateMsg := OnebotPrivateMessage{
RawMessage: messageText,
Message: segmentedMessages,
MessageID: messageID,
MessageType: "private",
PostType: "message",
SelfID: int64(p.Settings.AppID),
SelfID: selfid64,
UserID: userid64,
Sender: PrivateSender{
Nickname: data.Member.Nick,
Expand Down Expand Up @@ -183,14 +193,22 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
p.HandleFrameworkCommand(messageText, data, "guild_private")
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
echostr := AppIDString + "_" + strconv.FormatInt(s, 10)
// 获取当前时间的13位毫秒级时间戳
currentTimeMillis := time.Now().UnixNano() / 1e6
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)
//映射str的userid到int
userid64, err := idmap.StoreIDv2(data.Author.ID)
if err != nil {
mylog.Printf("Error storing ID: %v", err)
return nil
}
var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}
//OnebotChannelMessage
onebotMsg := OnebotChannelMessage{
ChannelID: data.ChannelID,
Expand All @@ -200,7 +218,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
MessageID: data.ID,
MessageType: "guild",
PostType: "message",
SelfID: int64(p.Settings.AppID),
SelfID: selfid64,
UserID: userid64,
SelfTinyID: "",
Sender: Sender{
Expand Down Expand Up @@ -271,16 +289,16 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
var err error
if config.GetIdmapPro() {
//将真实id转为int userid64
_, _, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID)
ChannelID64, userid64, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID)
if err != nil {
mylog.Fatalf("Error storing ID: %v", err)
}
//将真实id转为int userid64
userid64, err = idmap.StoreIDv2(data.Author.ID)
_, err = idmap.StoreIDv2(data.Author.ID)
if err != nil {
mylog.Fatalf("Error storing ID: %v", err)
}
ChannelID64, err = idmap.StoreIDv2(data.ChannelID)
_, err = idmap.StoreIDv2(data.ChannelID)
if err != nil {
mylog.Printf("Error storing ID: %v", err)
return nil
Expand Down Expand Up @@ -319,8 +337,10 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
p.HandleFrameworkCommand(messageText, data, "guild_private")
//转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)
//构造echo
echostr := AppIDString + "_" + strconv.FormatInt(s, 10)
// 获取当前时间的13位毫秒级时间戳
currentTimeMillis := time.Now().UnixNano() / 1e6
// 构造echostr,包括AppID,原始的s变量和当前时间戳
echostr := fmt.Sprintf("%s_%d_%d", AppIDString, s, currentTimeMillis)

//userid := int(userid64)
//映射str的messageID到int
Expand All @@ -341,14 +361,22 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
} else {
IsBindedUserId = idmap.CheckValuev2(userid64)
}

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}

groupMsg := OnebotGroupMessage{
RawMessage: messageText,
Message: segmentedMessages,
MessageID: messageID,
GroupID: ChannelID64,
MessageType: "group",
PostType: "message",
SelfID: int64(p.Settings.AppID),
SelfID: selfid64,
UserID: userid64,
Sender: Sender{
Nickname: data.Member.Nick,
Expand Down
23 changes: 19 additions & 4 deletions Processor/ProcessGroupAddBot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hoshinonyaruko/gensokyo/callapi"
"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"
Expand Down Expand Up @@ -93,15 +94,21 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error {
mylog.Printf("Invalid type for timestamp: %T", v)
return nil
}

mylog.Printf("Bot被[%v]邀请进入群[%v]", userid64, GroupID64)

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}

Request = GroupRequestEvent{
Comment: "",
Flag: "",
GroupID: GroupID64,
PostType: "request",
RequestType: "group",
SelfID: int64(config.GetAppID()),
SelfID: selfid64,
SubType: "invite",
Time: timestampInt64,
UserID: userid64,
Expand All @@ -111,7 +118,7 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error {
NoticeType: "group_increase",
OperatorID: 0,
PostType: "notice",
SelfID: int64(config.GetAppID()),
SelfID: selfid64,
SubType: "invite",
Time: timestampInt64,
UserID: userid64,
Expand All @@ -124,6 +131,14 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error {
//上报信息到onebotv11应用端(正反ws)
p.BroadcastMessageToAll(groupMsgMap)

// 转换appid
AppIDString := strconv.FormatUint(p.Settings.AppID, 10)

// 储存和群号相关的eventid
echo.AddEvnetID(AppIDString, GroupID64, data.ID)

mylog.Printf("Bot被[%v]邀请进入群[%v]eventid[%v]", userid64, GroupID64, data.ID)

// 调用GetSelfIntroduce函数
intros := config.GetSelfIntroduce()

Expand Down
12 changes: 11 additions & 1 deletion Processor/ProcessGroupDelBot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package Processor

import (
"fmt"
"strconv"

"github.com/hoshinonyaruko/gensokyo/config"
Expand Down Expand Up @@ -50,12 +51,21 @@ func (p *Processors) ProcessGroupDelBot(data *dto.GroupAddBotEvent) error {
return nil
}
mylog.Printf("Bot被[%v]从群[%v]移出", userid64, GroupID64)
//从数据库删除群数据(仅删除类型缓存,再次加入会刷新)
idmap.DeleteConfigv2(fmt.Sprint(GroupID64), "type")

var selfid64 int64
if config.GetUseUin() {
selfid64 = config.GetUinint64()
} else {
selfid64 = int64(p.Settings.AppID)
}
Notice = GroupNoticeEvent{
GroupID: GroupID64,
NoticeType: "group_decrease",
OperatorID: 0,
PostType: "notice",
SelfID: int64(config.GetAppID()),
SelfID: selfid64,
SubType: "kick_me",
Time: timestampInt64,
UserID: userid64,
Expand Down
Loading
Loading