mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix typo.
This commit is contained in:
parent
a6bef48fe2
commit
ef3d1cab23
@ -2,7 +2,7 @@
|
||||
qq-android协议的golang实现 移植于Mirai
|
||||
|
||||
# 警告
|
||||
本项目目前还处于玩具阶段,强烈不推荐使用.
|
||||
本项目目前还处于功能填充阶段,将来API和项目结构可能会有调整,目前不推荐使用。
|
||||
|
||||
# 已完成功能/开发计划
|
||||
#### 登录
|
||||
@ -14,6 +14,7 @@ qq-android协议的golang实现 移植于Mirai
|
||||
#### 消息类型
|
||||
- [x] 文本
|
||||
- [x] 图片
|
||||
- [x] 表情
|
||||
- [x] At
|
||||
- [x] 回复
|
||||
- [ ] 长消息
|
||||
|
@ -3,6 +3,7 @@ package client
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb"
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
@ -187,7 +188,7 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) SendGroupMessage(groupUin int64, m *message.SendingMessage) int32 {
|
||||
func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage) int32 {
|
||||
eid := utils.RandomString(6)
|
||||
mr := int32(rand.Uint32())
|
||||
ch := make(chan int32)
|
||||
@ -197,7 +198,7 @@ func (c *QQClient) SendGroupMessage(groupUin int64, m *message.SendingMessage) i
|
||||
c.onGroupMessageReceipt(eid)
|
||||
}
|
||||
})
|
||||
_, pkt := c.buildGroupSendingPacket(utils.ToGroupCode(groupUin), mr, m)
|
||||
_, pkt := c.buildGroupSendingPacket(groupCode, mr, m)
|
||||
_ = c.send(pkt)
|
||||
var mid int32
|
||||
select {
|
||||
@ -321,7 +322,7 @@ func (c *QQClient) FindFriend(uin int64) *FriendInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *QQClient) FindGroup(uin int64) *GroupInfo {
|
||||
func (c *QQClient) FindGroupByUin(uin int64) *GroupInfo {
|
||||
for _, g := range c.GroupList {
|
||||
f := g
|
||||
if f.Uin == uin {
|
||||
@ -331,6 +332,16 @@ func (c *QQClient) FindGroup(uin int64) *GroupInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *QQClient) FindGroup(code int64) *GroupInfo {
|
||||
for _, g := range c.GroupList {
|
||||
f := g
|
||||
if f.Code == code {
|
||||
return f
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo {
|
||||
for _, m := range g.Members {
|
||||
f := m
|
||||
@ -451,7 +462,7 @@ func (c *QQClient) loop() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
//fmt.Println(pkt.CommandName)
|
||||
fmt.Println(pkt.CommandName)
|
||||
go func() {
|
||||
decoder, ok := c.decoders[pkt.CommandName]
|
||||
if !ok {
|
||||
|
@ -155,10 +155,10 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
|
||||
switch message.Head.MsgType {
|
||||
case 33:
|
||||
groupJoinLock.Lock()
|
||||
group := c.FindGroup(message.Head.FromUin)
|
||||
group := c.FindGroupByUin(message.Head.FromUin)
|
||||
if message.Head.AuthUin == c.Uin {
|
||||
if group == nil && c.ReloadGroupList() == nil {
|
||||
c.dispatchJoinGroupEvent(c.FindGroup(message.Head.FromUin))
|
||||
c.dispatchJoinGroupEvent(c.FindGroupByUin(message.Head.FromUin))
|
||||
}
|
||||
} else {
|
||||
if group != nil && group.FindMember(message.Head.AuthUin) == nil {
|
||||
@ -366,7 +366,7 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
|
||||
target := int64(uint32(r.ReadInt32()))
|
||||
t := r.ReadInt32()
|
||||
c.dispatchGroupMuteEvent(&GroupMuteEvent{
|
||||
GroupUin: groupId,
|
||||
GroupCode: groupId,
|
||||
OperatorUin: operator,
|
||||
TargetUin: target,
|
||||
Time: t,
|
||||
@ -380,7 +380,7 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
|
||||
}
|
||||
for _, rm := range b.OptMsgRecall.RecalledMsgList {
|
||||
c.dispatchGroupMessageRecalledEvent(&GroupMessageRecalledEvent{
|
||||
GroupUin: groupId,
|
||||
GroupCode: groupId,
|
||||
OperatorUin: b.OptMsgRecall.Uin,
|
||||
AuthorUin: rm.AuthorUin,
|
||||
MessageId: rm.Seq,
|
||||
@ -400,7 +400,7 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
|
||||
return nil, err
|
||||
}
|
||||
groupLeaveLock.Lock()
|
||||
if g := c.FindGroup(d4.Uin); g != nil {
|
||||
if g := c.FindGroupByUin(d4.Uin); g != nil {
|
||||
if err := c.ReloadGroupList(); err != nil {
|
||||
groupLeaveLock.Unlock()
|
||||
return nil, err
|
||||
@ -428,7 +428,7 @@ func decodeOnlinePushTransPacket(c *QQClient, _ uint16, payload []byte) (interfa
|
||||
target := int64(uint32(data.ReadInt32()))
|
||||
typ := int32(data.ReadByte())
|
||||
operator := int64(uint32(data.ReadInt32()))
|
||||
if g := c.FindGroup(info.FromUin); g != nil {
|
||||
if g := c.FindGroupByUin(info.FromUin); g != nil {
|
||||
switch typ {
|
||||
case 0x03:
|
||||
groupLeaveLock.Lock()
|
||||
@ -469,7 +469,7 @@ func decodeOnlinePushTransPacket(c *QQClient, _ uint16, payload []byte) (interfa
|
||||
if var4 != 0 && var4 != 1 {
|
||||
var5 = int64(uint32(data.ReadInt32()))
|
||||
}
|
||||
if g := c.FindGroup(info.FromUin); g != nil {
|
||||
if g := c.FindGroupByUin(info.FromUin); g != nil {
|
||||
if var5 == 0 && data.Len() == 1 {
|
||||
newPermission := func() MemberPermission {
|
||||
if data.ReadByte() == 1 {
|
||||
|
@ -67,14 +67,14 @@ type (
|
||||
}
|
||||
|
||||
GroupMuteEvent struct {
|
||||
GroupUin int64
|
||||
GroupCode int64
|
||||
OperatorUin int64
|
||||
TargetUin int64
|
||||
Time int32
|
||||
}
|
||||
|
||||
GroupMessageRecalledEvent struct {
|
||||
GroupUin int64
|
||||
GroupCode int64
|
||||
OperatorUin int64
|
||||
AuthorUin int64
|
||||
MessageId int32
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
devinfo "github.com/Mrs4s/MiraiGo/client/pb"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"math/rand"
|
||||
)
|
||||
@ -98,7 +97,7 @@ func (info *DeviceInfo) GenNewTgtgtKey() {
|
||||
}
|
||||
|
||||
func (info *DeviceInfo) GenDeviceInfoData() []byte {
|
||||
msg := &devinfo.DeviceInfo{
|
||||
m := &devinfo.DeviceInfo{
|
||||
Bootloader: string(info.Bootloader),
|
||||
ProcVersion: string(info.ProcVersion),
|
||||
Codename: string(info.Version.CodeName),
|
||||
@ -109,7 +108,7 @@ func (info *DeviceInfo) GenDeviceInfoData() []byte {
|
||||
BaseBand: string(info.BaseBand),
|
||||
InnerVersion: string(info.Version.Incremental),
|
||||
}
|
||||
data, err := proto.Marshal(msg)
|
||||
data, err := proto.Marshal(m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -132,7 +131,7 @@ func (c *QQClient) parsePrivateMessage(msg *msg.Message) *message.PrivateMessage
|
||||
}
|
||||
|
||||
func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
||||
group := c.FindGroup(utils.ToGroupUin(m.Head.GroupInfo.GroupCode))
|
||||
group := c.FindGroup(m.Head.GroupInfo.GroupCode)
|
||||
if group == nil {
|
||||
return nil
|
||||
}
|
||||
@ -163,7 +162,7 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
||||
}
|
||||
g := &message.GroupMessage{
|
||||
Id: m.Head.MsgSeq,
|
||||
GroupUin: group.Uin,
|
||||
GroupCode: group.Code,
|
||||
GroupName: string(m.Head.GroupInfo.GroupName),
|
||||
Sender: sender,
|
||||
Elements: parseMessageElems(m.Body.RichText.Elems),
|
||||
|
@ -14,7 +14,7 @@ type PrivateMessage struct {
|
||||
|
||||
type GroupMessage struct {
|
||||
Id int32
|
||||
GroupUin int64
|
||||
GroupCode int64
|
||||
GroupName string
|
||||
Sender *Sender
|
||||
Elements []IMessageElement
|
||||
|
Loading…
x
Reference in New Issue
Block a user