Skip to content

Commit 4dfbe03

Browse files
committed
reply
1 parent f0b976f commit 4dfbe03

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ device.json
3737
Go-Mirai-Client
3838
device-*.json
3939
static/
40-
gmc-*.zip
40+
gmc-*.zip
41+
captcha.jpg

service/bot/bot.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package bot
33
import (
44
"io/ioutil"
55
"os"
6-
"strings"
76
"sync"
87
"time"
98

109
"github.com/Mrs4s/MiraiGo/client"
10+
"github.com/Mrs4s/MiraiGo/utils"
1111
"github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
1212
"github.com/fanliao/go-promise"
1313
log "github.com/sirupsen/logrus"
@@ -20,22 +20,23 @@ func InitDevice(path string) {
2020
if !util.PathExists(path) {
2121
log.Warn("虚拟设备信息不存在, 将自动生成随机设备.")
2222
client.GenRandomDevice()
23-
client.SystemDeviceInfo.Display = []byte(strings.Replace(string(client.SystemDeviceInfo.Display), "MIRAI", "GMC", -1))
24-
client.SystemDeviceInfo.FingerPrint = []byte(strings.Replace(string(client.SystemDeviceInfo.FingerPrint), "MIRAI", "GMC", -1))
25-
client.SystemDeviceInfo.FingerPrint = []byte(strings.Replace(string(client.SystemDeviceInfo.FingerPrint), "mirai", "gmc", -1))
26-
client.SystemDeviceInfo.FingerPrint = []byte(strings.Replace(string(client.SystemDeviceInfo.FingerPrint), "mamoe", "pbbot", -1))
23+
client.SystemDeviceInfo.Display = []byte("GMC." + utils.RandomStringRange(6, "0123456789") + ".001")
24+
client.SystemDeviceInfo.FingerPrint = []byte("pbbot/gmc/gmc:10/PBBOT.200324.001/" + utils.RandomStringRange(7, "0123456789") + ":user/release-keys")
25+
client.SystemDeviceInfo.ProcVersion = []byte("Linux version 4.0.8-" + utils.RandomString(8) + " ([email protected])")
26+
client.SystemDeviceInfo.AndroidId = client.SystemDeviceInfo.Display
2727
client.SystemDeviceInfo.Device = []byte("gmc")
2828
client.SystemDeviceInfo.Board = []byte("gmc")
2929
client.SystemDeviceInfo.Model = []byte("gmc")
3030
client.SystemDeviceInfo.Brand = []byte("pbbot")
3131
client.SystemDeviceInfo.Product = []byte("gmc")
32+
client.SystemDeviceInfo.Protocol = client.MacOS
3233
_ = ioutil.WriteFile(path, client.SystemDeviceInfo.ToJson(), 0644)
3334
log.Infof("已生成设备信息并保存到 %s 文件.", path)
34-
} else {
35-
log.Infof("将使用 %s 内的设备信息运行", path)
36-
if err := client.SystemDeviceInfo.ReadJson([]byte(util.ReadAllText(path))); err != nil {
37-
log.Fatalf("加载设备信息失败: %v", err)
38-
}
35+
}
36+
log.Infof("将使用 %s 内的设备信息运行", path)
37+
client.SystemDeviceInfo.IpAddress = []byte{192, 168, 31, 101}
38+
if err := client.SystemDeviceInfo.ReadJson([]byte(util.ReadAllText(path))); err != nil {
39+
log.Fatalf("加载设备信息失败: %v", err)
3940
}
4041
}
4142

service/bot/captcha.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func ProcessLoginRsp(cli *client.QQClient, rsp *client.LoginResponse) (bool, err
3737
time.Sleep(5 * time.Second)
3838
os.Exit(0)
3939
}
40+
log.Warnf("遇到不支持的滑块验证码,重新登陆")
4041
cli.AllowSlider = false
4142
cli.Disconnect()
4243
rsp, err := cli.Login()

service/bot/mirai2proto.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ func MiraiMsgToProtoMsg(messageChain []message.IMessageElement) []*onebot.Messag
2727
msgList = append(msgList, MiraiLightAppToProtoLightApp(elem))
2828
case *message.ShortVideoElement:
2929
msgList = append(msgList, MiraiVideoToProtoVideo(elem))
30+
case *message.ReplyElement:
31+
msgList = append(msgList, MiraiReplyToProtoReply(elem))
3032
}
3133
}
3234
return msgList
@@ -114,3 +116,15 @@ func MiraiVideoToProtoVideo(elem *message.ShortVideoElement) *onebot.Message {
114116
},
115117
}
116118
}
119+
120+
func MiraiReplyToProtoReply(elem *message.ReplyElement) *onebot.Message {
121+
return &onebot.Message{
122+
Type: "reply",
123+
Data: map[string]string{
124+
"reply_seq": strconv.FormatInt(int64(elem.ReplySeq), 10),
125+
"sender": strconv.FormatInt(elem.Sender, 10),
126+
"time": strconv.FormatInt(int64(elem.Time), 10),
127+
"raw_message": MiraiMsgToRawMsg(elem.Elements),
128+
},
129+
}
130+
}

service/bot/mirai2raw.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ func MiraiMsgToRawMsg(messageChain []message.IMessageElement) string {
2727
result += fmt.Sprintf(`<light_app content="%s"/>`, html.EscapeString(elem.Content))
2828
case *message.ShortVideoElement:
2929
result += fmt.Sprintf(`<video name="%s" url="%s"/>`, html.EscapeString(elem.Name), html.EscapeString(elem.Url))
30+
case *message.ReplyElement:
31+
result += fmt.Sprintf(`<reply time="%d" sender="%d" raw_message="%s" reply_seq="%d"/>`, elem.Time, elem.Sender, MiraiMsgToRawMsg(elem.Elements), elem.ReplySeq)
3032
}
3133
}
3234
return result

0 commit comments

Comments
 (0)