From 8968352f7290ff4c9734b4a9cc9243075f55a63e Mon Sep 17 00:00:00 2001 From: wangxiaowen Date: Tue, 9 Apr 2024 12:38:04 +0800 Subject: [PATCH 1/4] fix lack of GetSenderUid function --- v2/events/events.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v2/events/events.go b/v2/events/events.go index 368cd70..9bfd044 100644 --- a/v2/events/events.go +++ b/v2/events/events.go @@ -72,6 +72,7 @@ type IGroupMsg interface { GetGroupInfo() GroupInfo GetSenderNick() string GetSenderUin() int64 + GetSenderUid() string ParseTextMsg() ITextMsg ParsePicMsg() IPicMsg ContainedPic() bool @@ -256,6 +257,9 @@ func (e *EventStruct) ExcludeBot() IEvent { func (e *EventStruct) GetSenderUin() int64 { return e.CurrentPacket.EventData.MsgHead.SenderUin } +func (e *EventStruct) GetSenderUid() string { + return e.CurrentPacket.EventData.MsgHead.SenderUid +} func (e *EventStruct) GetSenderNick() string { return e.CurrentPacket.EventData.MsgHead.SenderNick } From b132cd9b65ec7e7f2019ed6a722c7a09aafb78e1 Mon Sep 17 00:00:00 2001 From: ThinkerWen <296854007@qq.com> Date: Mon, 15 Apr 2024 14:44:44 +0800 Subject: [PATCH 2/4] =?UTF-8?q?add=20=E6=8B=8D=E4=B8=80=E6=8B=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/apiBuilder/groupManager.go | 14 ++++++++++++++ v2/events/events.go | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/v2/apiBuilder/groupManager.go b/v2/apiBuilder/groupManager.go index 3f87332..0578009 100644 --- a/v2/apiBuilder/groupManager.go +++ b/v2/apiBuilder/groupManager.go @@ -7,6 +7,7 @@ type IGroupManager interface { GroupSystemMsgAction(MsgType int, MsgSeq, GroupCode int64) IGroupSystemMsgAction RevokeMsg() IGroupManager ToGUin(Uin int64) IGroupManager + ToGroupCode(Uin int64) IGroupManager MsgSeq(MsgSeq int64) IGroupManager MsgRandom(MsgRandom int64) IGroupManager ProhibitedUser() IGroupManager @@ -14,6 +15,7 @@ type IGroupManager interface { ShutTime(ShutTime int) IGroupManager RemoveUser() IGroupManager RenameUserNickName(NickName string) IGroupManager + Pat(Uin int64) IGroupManager } type IGroupSystemMsgAction interface { DoApi @@ -97,6 +99,11 @@ func (b *Builder) ToGUin(Uin int64) IGroupManager { return b } +func (b *Builder) ToGroupCode(GroupCode int64) IGroupManager { + b.CgiRequest.GroupCode = &GroupCode + return b +} + func (b *Builder) ToUid(Uid string) IGroupManager { b.CgiRequest.Uid = &Uid return b @@ -141,3 +148,10 @@ func (b *Builder) RenameUserNickName(NickName string) IGroupManager { return b } + +func (b *Builder) Pat(Uin int64) IGroupManager { + cmd := "SsoGroup.Op.Pat" + b.CgiCmd = &cmd + b.CgiRequest.Uin = &Uin + return b +} diff --git a/v2/events/events.go b/v2/events/events.go index 9bfd044..b06483a 100644 --- a/v2/events/events.go +++ b/v2/events/events.go @@ -73,6 +73,7 @@ type IGroupMsg interface { GetSenderNick() string GetSenderUin() int64 GetSenderUid() string + GetToUin() int64 ParseTextMsg() ITextMsg ParsePicMsg() IPicMsg ContainedPic() bool @@ -260,6 +261,9 @@ func (e *EventStruct) GetSenderUin() int64 { func (e *EventStruct) GetSenderUid() string { return e.CurrentPacket.EventData.MsgHead.SenderUid } +func (e *EventStruct) GetToUin() int64 { + return e.CurrentPacket.EventData.MsgHead.ToUin +} func (e *EventStruct) GetSenderNick() string { return e.CurrentPacket.EventData.MsgHead.SenderNick } From 0a4a25dce79cc7ed9819bdf04450cdfb4979e052 Mon Sep 17 00:00:00 2001 From: ThinkerWen <296854007@qq.com> Date: Wed, 17 Apr 2024 15:08:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?add=20=E5=9B=9E=E5=A4=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20=E8=AF=AD=E9=9F=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/test.amr | Bin 0 -> 3302 bytes v2/apiBuilder/opqapi.go | 5 +++++ v2/apiBuilder/sendMsg.go | 24 ++++++++++++++++++++++++ v2/example/main.go | 16 ++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 example/test.amr diff --git a/example/test.amr b/example/test.amr new file mode 100644 index 0000000000000000000000000000000000000000..dd1494b4822379dd3ddac88700b5c03c51809c5a GIT binary patch literal 3302 zcmYjSc{J307ytdtG*OnZPnIz<*0D@tNZ%OyE;~`OWlM~;K`~@s9+M>58e~gJdXyfO z{dp*bp&m*M9#3{d+Yoxa=l$os=iGD8x%ZrV&*yXQ{aiU&LtDo~z!KNkEMc5X%bOQq zMZ0j(AW|Ol$6Y!EH@2Lrwxxq9W?W&vFAr=LU?r$%)%(t-#p9FGo*1M2DV;TjfI#Y0 zh7!iRK6}u*duwZK+ivt{@bW}LLqS^W@X$^*8xT*OFKJ++MF<-?opXDL{%Oh&Hu;gr4h_dDF|{Y6j{~cqP>7jd&A($ppgLZod?JH6NWA zw!0+}&d+{L14JEF3QBoq2p#GH3KP2d-8_)|;R8*=YbJcfv*Tnyypn+73%=$By&q)6 zUG)zb(BR{L5qneq&o$3a{%ULh=&?AdhHyR8)TqC2eouv-uJ*b_uh)Z$AIz9_<8{G$Ss6pAIW#hVRbR*=R4myV45;i>Df^u_78B8YmeU@L2Jst}6qpc%Me|)) zn=i+i{mcq|t{$Wv_RHM1raut^u1jJVIG^RkEusCF>6WJJ?aJs8p9T~87&CG^N{I!+ z&LvO~#@!Vd?bRMwc%}BbS^B+Xn(d~$qnc!v1R7v>&*Av&>huxUdJew$wC?vH7qI15mdEG04S@JqfG$ z&^zQ8J!VZrQ|N(JsvQr1i?0j~lz2vC;KK`vBFM5dt%1eCN-H6UFl)_gbLU@m{?XzM zLYDoN;%?6DNvh*e=E z(*eikOt}?Q`U{~T_2<(o-5=Z*O4&N&vo_RS38|Uj{r>uRO>0LO-my%5*}6^ml8Nbh zl&8X1bZDaQL5wI7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x07ElcSQ7k*?7V{)eJZpqIBO##FXgDH&Lfw!SYPg&nJA!PJ3nw z>#H%D`~3N^v}3ITG-S)~yFZxEl@_D+99TW0q;KKQkk7fhudm{X{YO`<47gI%Y8jvh{)znz%fkXP_@%Zr7GiItb{@bP0vAaoE(YtIGm^vSH=Nua%kIIj2P2|I5q0s z&4p!Ahm+Qu^+igyMNWKs#b7Y5Q=Z{+kKh1n)&DnB9FO;{jHP}ovr{D{Q}ZSJrVB|T z`tsPO83gPiqwnmFLpYDBlEvKi%T;Q0=>CK5BzQ{Xj=v;wfBvde#~Bz+=6jRvS!u=l zD#N0>Q5ioFt8UvMIQqvH#fH=z7G7WK>E$t% zDJ&RYWB>*Jl1_w&{I)CUl$+ Date: Wed, 17 Apr 2024 19:32:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?add=20=E7=BB=84=E5=90=88=E6=B6=88=E6=81=AF?= =?UTF-8?q?=20markdown=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/apiBuilder/opqapi.go | 59 ++++++++++++++++++++++++++-------------- v2/apiBuilder/sendMsg.go | 27 ++++++++++++++++++ v2/apiBuilder/upload.go | 1 + v2/example/main.go | 13 +++++++++ 4 files changed, 79 insertions(+), 21 deletions(-) diff --git a/v2/apiBuilder/opqapi.go b/v2/apiBuilder/opqapi.go index 094d9fd..a99d8e8 100644 --- a/v2/apiBuilder/opqapi.go +++ b/v2/apiBuilder/opqapi.go @@ -24,27 +24,30 @@ type Builder struct { CgiRequest *CgiRequest `json:"CgiRequest,omitempty"` } type CgiRequest struct { - LastUin *int64 `json:"LastUin,omitempty"` - OpCode *int `json:"OpCode,omitempty"` - MsgSeq *int64 `json:"MsgSeq,omitempty"` - MsgType *int `json:"MsgType,omitempty"` - GroupCode *int64 `json:"GroupCode,omitempty"` - Uin *int64 `json:"Uin,omitempty"` - LastBuffer *string `json:"LastBuffer,omitempty"` - CommandId *int `json:"CommandId,omitempty"` - FilePath *string `json:"FilePath,omitempty"` - Base64Buf *string `json:"Base64Buf,omitempty"` - FileUrl *string `json:"FileUrl,omitempty"` - ToUin *int64 `json:"ToUin,omitempty"` - ToType *int `json:"ToType,omitempty"` - Content *string `json:"Content,omitempty"` - SubMsgType *int `json:"SubMsgType,omitempty"` - Images []*File `json:"Images,omitempty"` - Voice *File `json:"Voice,omitempty"` - Uid *string `json:"Uid,omitempty"` - MsgRandom *int64 `json:"MsgRandom,omitempty"` - BanTime *int `json:"BanTime,omitempty"` - Nick *string `json:"Nick,omitempty"` + LastUin *int64 `json:"LastUin,omitempty"` + OpCode *int `json:"OpCode,omitempty"` + MsgSeq *int64 `json:"MsgSeq,omitempty"` + MsgType *int `json:"MsgType,omitempty"` + GroupCode *int64 `json:"GroupCode,omitempty"` + Uin *int64 `json:"Uin,omitempty"` + LastBuffer *string `json:"LastBuffer,omitempty"` + CommandId *int `json:"CommandId,omitempty"` + FilePath *string `json:"FilePath,omitempty"` + Base64Buf *string `json:"Base64Buf,omitempty"` + FileUrl *string `json:"FileUrl,omitempty"` + ToUin *int64 `json:"ToUin,omitempty"` + ToType *int `json:"ToType,omitempty"` + Content *string `json:"Content,omitempty"` + SubMsgType *int `json:"SubMsgType,omitempty"` + MsgBodys []*MsgBody `json:"MsgBodys,omitempty"` + Images []*File `json:"Images,omitempty"` + Voice *File `json:"Voice,omitempty"` + Markdown *string `json:"Markdown,omitempty"` + Keyboard []*map[string][]*Button `json:"Keyboard,omitempty"` + Uid *string `json:"Uid,omitempty"` + MsgRandom *int64 `json:"MsgRandom,omitempty"` + BanTime *int `json:"BanTime,omitempty"` + Nick *string `json:"Nick,omitempty"` AtUinLists []struct { Uin *int64 `json:"Uin,omitempty"` } `json:"AtUinLists,omitempty"` @@ -53,6 +56,20 @@ type CgiRequest struct { MsgUid *int64 `json:"MsgUid,omitempty"` } `json:"ReplyTo,omitempty"` } +type MsgBody struct { + Content *string `json:"Content,omitempty"` + Image *File `json:"Image,omitempty"` +} +type Button struct { + ID string `json:"Id"` + RenderDataLabel string `json:"RenderDataLabel"` + RenderDataVisitedLabel string `json:"RenderDataVisitedLabel"` + RenderDataStyle int `json:"RenderDataStyle"` + ActionType int `json:"ActionType"` + ActionPermissonType int `json:"ActionPermissonType"` + ActionData string `json:"ActionData"` + ActionUnsupportTips string `json:"ActionUnsupportTips"` +} func (b *Builder) BuildStringBody() (string, error) { body, err := json.Marshal(b) diff --git a/v2/apiBuilder/sendMsg.go b/v2/apiBuilder/sendMsg.go index a1741ec..e723c8a 100644 --- a/v2/apiBuilder/sendMsg.go +++ b/v2/apiBuilder/sendMsg.go @@ -13,7 +13,10 @@ type IMsg interface { VoiceMsg(voice *File) IMsg XmlMsg(xml string) IMsg JsonMsg(json string) IMsg + MultiMsg(msgBody ...*MsgBody) IMsg + MarkDownMsg(text string) IMsg At(uint ...int64) IMsg + Buttons(keys ...*Button) IMsg DoApi } @@ -106,6 +109,22 @@ func (b *Builder) JsonMsg(json string) IMsg { b.CgiRequest.Content = &json return b } +func (b *Builder) MultiMsg(msgBodys ...*MsgBody) IMsg { + if b.CgiRequest == nil { + b.CgiRequest = &CgiRequest{} + } + cmd := "SsoUploadMultiMsg" + b.CgiCmd = &cmd + b.CgiRequest.MsgBodys = msgBodys + return b +} +func (b *Builder) MarkDownMsg(md string) IMsg { + if b.CgiRequest == nil { + b.CgiRequest = &CgiRequest{} + } + b.CgiRequest.Markdown = &md + return b +} func (b *Builder) At(uin ...int64) IMsg { if b.CgiRequest == nil { b.CgiRequest = &CgiRequest{} @@ -118,3 +137,11 @@ func (b *Builder) At(uin ...int64) IMsg { } return b } +func (b *Builder) Buttons(keys ...*Button) IMsg { + if b.CgiRequest == nil { + b.CgiRequest = &CgiRequest{} + } + bc := map[string][]*Button{"Buttons": keys} + b.CgiRequest.Keyboard = append(b.CgiRequest.Keyboard, &bc) + return b +} diff --git a/v2/apiBuilder/upload.go b/v2/apiBuilder/upload.go index f1795c8..578b2e1 100644 --- a/v2/apiBuilder/upload.go +++ b/v2/apiBuilder/upload.go @@ -84,6 +84,7 @@ type File struct { FileId int64 `json:"FileId"` Height int `json:"Height"` Width int `json:"Width"` + Url string `json:"Url"` } func (b *Builder) DoUpload(ctx context.Context) (*File, error) { diff --git a/v2/example/main.go b/v2/example/main.go index f838877..a341350 100644 --- a/v2/example/main.go +++ b/v2/example/main.go @@ -40,6 +40,19 @@ func main() { if text == "reply" { apiBuilder.New(apiUrl, event.GetCurrentQQ()).SendMsg().GroupMsg().ToUin(groupMsg.GetGroupUin()).TextMsg("回复").ReplyMsg(groupMsg.GetMsgSeq(), groupMsg.GetMsgUid()).Do(ctx) } + if text == "md" { + btn1 := &apiBuilder.Button{ + ID: "1", + RenderDataLabel: "⬅️客户端内访问", + RenderDataVisitedLabel: "⬅️客户端内访问", + RenderDataStyle: 0, + ActionType: 0, + ActionPermissonType: 2, + ActionData: "https://q.qq.com/", + ActionUnsupportTips: "兼容文本", + } + apiBuilder.New(apiUrl, event.GetCurrentQQ()).SendMsg().GroupMsg().ToUin(groupMsg.GetGroupUin()).MarkDownMsg("# #一号标题 \n").Buttons(btn1).Do(ctx) + } if text == "pic" { p, err := os.ReadFile("example/test.jpg") if err != nil {