From 6a990e62966aa0aa5d3ed20a5d22b339655004b6 Mon Sep 17 00:00:00 2001
From: mcoo <2435932516@qq.com>
Date: Sat, 15 May 2021 10:50:18 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E7=BE=A4=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8=20=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
example/main.go | 13 ++++++-------
main.go | 16 +++++++++++++++-
model.go | 24 ++++++++++++++++++++++++
3 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/example/main.go b/example/main.go
index fe7c97e..2b2eb0a 100644
--- a/example/main.go
+++ b/example/main.go
@@ -4,7 +4,6 @@ import (
"encoding/base64"
"fmt"
"github.com/mcoo/OPQBot"
- "github.com/mcoo/OPQBot/qzone"
"github.com/mcoo/requests"
"io/ioutil"
"log"
@@ -36,12 +35,12 @@ func main() {
// m = map[string]interface{}{"reason": "消息违规"}
// return m
//}))
- ck, _ := opqBot.GetUserCookie()
- qz := qzone.NewQzoneManager(opqBot.QQ, ck)
- f, _ := ioutil.ReadFile("./head.PNG")
- u, _ := qz.UploadPic(base64.StdEncoding.EncodeToString(f))
- bo, rich, _ := qzone.GetPicBoAndRichVal(u)
- log.Println(qz.SendShuoShuoWithPic("发送图文测试", bo, rich))
+ //ck, _ := opqBot.GetUserCookie()
+ //qz := qzone.NewQzoneManager(opqBot.QQ, ck)
+ //f, _ := ioutil.ReadFile("./head.PNG")
+ //u, _ := qz.UploadPic(base64.StdEncoding.EncodeToString(f))
+ //bo, rich, _ := qzone.GetPicBoAndRichVal(u)
+ //log.Println(qz.SendShuoShuoWithPic("发送图文测试", bo, rich))
//lists,_ :=qz.GetShuoShuoList()
//infoReg,_ := regexp.Compile(`
(.*?)
`)
//for _,v := range lists.Data.Data {
diff --git a/main.go b/main.go
index 7bdbc26..4c62dd6 100644
--- a/main.go
+++ b/main.go
@@ -665,6 +665,20 @@ func (b *BotManager) KickGroupMember(groupID, userId int64) error {
return nil
}
+// GetGroupMemberList 获取群成员列表
+func (b *BotManager) GetGroupMemberList(groupID, LastUin int64) (GroupMemberList, error) {
+ var result GroupMemberList
+ res, err := requests.PostJson(b.OPQUrl+"/v1/LuaApiCaller?funcname=friendlist.GetTroopMemberListReq&qq="+strconv.FormatInt(b.QQ, 10), map[string]interface{}{"GroupID": groupID, "LastUin": LastUin})
+ if err != nil {
+ return result, err
+ }
+ err = res.Json(&result)
+ if err != nil {
+ return result, err
+ }
+ return result, nil
+}
+
// SetGroupNewNick 设置群名片
func (b *BotManager) SetGroupNewNick(newNick string, groupID, userId int64) error {
var result Result
@@ -713,7 +727,7 @@ func (b *BotManager) GetFriendList(startIndex int) (FriendList, error) {
return result, nil
}
-// GetGroupList 获取好友列表
+// GetGroupList 获取群列表
func (b *BotManager) GetGroupList(nextToken string) (GroupList, error) {
var result GroupList
res, err := requests.PostJson(b.OPQUrl+"/v1/LuaApiCaller?funcname=friendlist.GetTroopListReqV2&timeout=10&qq="+strconv.FormatInt(b.QQ, 10), map[string]interface{}{"NextToken": nextToken})
diff --git a/model.go b/model.go
index f2ad84c..c272b13 100644
--- a/model.go
+++ b/model.go
@@ -380,6 +380,30 @@ type GroupFileResult struct {
Ret int `json:"Ret"`
URL string `json:"Url"`
}
+type GroupMemberList struct {
+ Count int `json:"Count"`
+ GroupUin int `json:"GroupUin"`
+ LastUin int `json:"LastUin"`
+ MemberList []struct {
+ Age int `json:"Age"`
+ AutoRemark string `json:"AutoRemark"`
+ CreditLevel int `json:"CreditLevel"`
+ Email string `json:"Email"`
+ FaceID int `json:"FaceId"`
+ Gender int `json:"Gender"`
+ GroupAdmin int `json:"GroupAdmin"`
+ GroupCard string `json:"GroupCard"`
+ JoinTime int `json:"JoinTime"`
+ LastSpeakTime int `json:"LastSpeakTime"`
+ MemberLevel int `json:"MemberLevel"`
+ MemberUin int `json:"MemberUin"`
+ Memo string `json:"Memo"`
+ NickName string `json:"NickName"`
+ ShowName string `json:"ShowName"`
+ SpecialTitle string `json:"SpecialTitle"`
+ Status int `json:"Status"`
+ } `json:"MemberList"`
+}
// FriendList 获取好友列表表单
type FriendList struct {
From 853e005daec97e97f3a95ac77dd40a56327e9746 Mon Sep 17 00:00:00 2001
From: mcoo <2435932516@qq.com>
Date: Sat, 15 May 2021 11:10:29 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E7=BE=A4=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8=20=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.go b/main.go
index 4c62dd6..44b99f3 100644
--- a/main.go
+++ b/main.go
@@ -668,7 +668,7 @@ func (b *BotManager) KickGroupMember(groupID, userId int64) error {
// GetGroupMemberList 获取群成员列表
func (b *BotManager) GetGroupMemberList(groupID, LastUin int64) (GroupMemberList, error) {
var result GroupMemberList
- res, err := requests.PostJson(b.OPQUrl+"/v1/LuaApiCaller?funcname=friendlist.GetTroopMemberListReq&qq="+strconv.FormatInt(b.QQ, 10), map[string]interface{}{"GroupID": groupID, "LastUin": LastUin})
+ res, err := requests.PostJson(b.OPQUrl+"/v1/LuaApiCaller?funcname=friendlist.GetTroopMemberListReq&qq="+strconv.FormatInt(b.QQ, 10), map[string]interface{}{"GroupUin": groupID, "LastUin": LastUin})
if err != nil {
return result, err
}
From 293e76c95fc965728f6602dd5fef65f620557a78 Mon Sep 17 00:00:00 2001
From: mcoo <2435932516@qq.com>
Date: Sat, 15 May 2021 11:36:05 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E7=BE=A4=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8=20=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
go.mod | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/go.mod b/go.mod
index 78ef52f..3583b60 100644
--- a/go.mod
+++ b/go.mod
@@ -6,5 +6,5 @@ require (
github.com/dop251/goja v0.0.0-20210427212725-462d53687b0d
github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9
github.com/gorilla/websocket v1.4.2
- github.com/mcoo/requests v0.0.1-edited
-)
\ No newline at end of file
+ github.com/mcoo/requests v0.0.2-edited
+)
From 1355537dbed38f8163a094ba80668d5ed5393d05 Mon Sep 17 00:00:00 2001
From: mcoo <2435932516@qq.com>
Date: Sun, 23 May 2021 16:21:11 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E5=BF=AB=E6=8D=B7=E5=8F=91=E4=BF=A1=E6=81=AF=E7=9A=84=E5=87=BD?=
=?UTF-8?q?=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.go | 89 +++++++++++++++++++++++++++++++++++++++++++++++++-------
model.go | 20 ++++++-------
2 files changed, 89 insertions(+), 20 deletions(-)
diff --git a/main.go b/main.go
index 44b99f3..c49bd83 100644
--- a/main.go
+++ b/main.go
@@ -6,12 +6,6 @@ import (
"encoding/base64"
"encoding/json"
"errors"
- "github.com/goinggo/mapstructure"
- gosocketio "github.com/mcoo/OPQBot/golang-socketio-edit"
- "github.com/mcoo/OPQBot/golang-socketio-edit/transport"
- "github.com/mcoo/OPQBot/session"
- _ "github.com/mcoo/OPQBot/session/provider"
- "github.com/mcoo/requests"
"io/ioutil"
"log"
"math/big"
@@ -24,6 +18,13 @@ import (
"strings"
"sync"
"time"
+
+ "github.com/goinggo/mapstructure"
+ gosocketio "github.com/mcoo/OPQBot/golang-socketio-edit"
+ "github.com/mcoo/OPQBot/golang-socketio-edit/transport"
+ "github.com/mcoo/OPQBot/session"
+ _ "github.com/mcoo/OPQBot/session/provider"
+ "github.com/mcoo/requests"
)
type BotManager struct {
@@ -154,13 +155,13 @@ func (b *BotManager) Start() error {
signal.Notify(interrupt, os.Interrupt, os.Kill)
go func() {
select {
- case _ = <-interrupt:
+ case <-interrupt:
log.Println("程序被用户终止,正在进行释放资源操作!")
b.MaxRetryCount = 0
b.Done <- 1
b.Done <- 2
b.wg.Done()
- case _ = <-restart:
+ case <-restart:
log.Println("程序重连尝试!")
b.Done <- 1
b.Done <- 2
@@ -180,7 +181,7 @@ func (b *BotManager) Start() error {
if len(b.myRecord) > 50 {
b.myRecordLocker.Lock()
for i, v := range b.myRecord {
- if time.Now().Sub(time.Unix(int64(v.MsgTime), 0)) > time.Second*180 {
+ if time.Since(time.Unix(int64(v.MsgTime), 0)) > time.Second*180 {
delete(b.myRecord, i)
}
}
@@ -1198,7 +1199,75 @@ OuterLoop:
}
time.Sleep(time.Duration(b.delayed) * time.Millisecond)
}
-
}
+}
+// SendFriendTextMsg 发送文字信息给好友
+func (b *BotManager) SendFriendTextMsg(FriendUin int64, Content string) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeFriend,
+ ToUserUid: FriendUin,
+ Content: SendTypeTextMsgContent{
+ Content: Content,
+ },
+ })
+}
+
+// SendFriendPicMsg 发送图片信息给好友
+func (b *BotManager) SendFriendPicMsg(FriendUin int64, Content string, Pic []byte) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeFriend,
+ ToUserUid: FriendUin,
+ Content: SendTypePicMsgByBase64Content{
+ Content: Content,
+ Base64: base64.StdEncoding.EncodeToString(Pic),
+ Flash: false,
+ },
+ })
+}
+
+// SendGroupTextMsg 发送文字信息给群
+func (b *BotManager) SendGroupTextMsg(GroupUin int64, Content string) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeGroup,
+ ToUserUid: GroupUin,
+ Content: SendTypeTextMsgContent{
+ Content: Content,
+ },
+ })
+}
+
+// SendGroupPicMsg 发送图片信息给群
+func (b *BotManager) SendGroupPicMsg(GroupUin int64, Content string, Pic []byte) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeGroup,
+ ToUserUid: GroupUin,
+ Content: SendTypePicMsgByBase64Content{
+ Content: Content,
+ Base64: base64.StdEncoding.EncodeToString(Pic),
+ Flash: false,
+ },
+ })
+}
+
+// SendGroupJsonMsg 发送JSON信息给群
+func (b *BotManager) SendGroupJsonMsg(GroupUin int64, Content string) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeGroup,
+ ToUserUid: GroupUin,
+ Content: SendTypeJsonContent{
+ Content: Content,
+ },
+ })
+}
+
+// SendGroupXmlMsg 发送Xml信息给群
+func (b *BotManager) SendGroupXmlMsg(GroupUin int64, Content string) {
+ b.Send(SendMsgPack{
+ SendToType: SendToTypeGroup,
+ ToUserUid: GroupUin,
+ Content: SendTypeXmlContent{
+ Content: Content,
+ },
+ })
}
diff --git a/model.go b/model.go
index c272b13..de98b55 100644
--- a/model.go
+++ b/model.go
@@ -290,7 +290,7 @@ type GroupAdminSysNotifyPack struct {
Flag8 int `json:"Flag_8"`
GroupID int64 `json:"GroupId"`
GroupName string `json:"GroupName"`
- ActionUin int `json:"ActionUin"`
+ ActionUin int64 `json:"ActionUin"`
ActionName string `json:"ActionName"`
ActionGroupCard string `json:"ActionGroupCard"`
Action int `json:"Action"`
@@ -373,7 +373,7 @@ type UserCardInfo struct {
type FriendFileResult struct {
FileName string `json:"FileName"`
FileSize int `json:"FileSize"`
- FromUin int `json:"FromUin"`
+ FromUin int64 `json:"FromUin"`
URL string `json:"Url"`
}
type GroupFileResult struct {
@@ -381,9 +381,9 @@ type GroupFileResult struct {
URL string `json:"Url"`
}
type GroupMemberList struct {
- Count int `json:"Count"`
- GroupUin int `json:"GroupUin"`
- LastUin int `json:"LastUin"`
+ Count int `json:"Count"`
+ GroupUin int64 `json:"GroupUin"`
+ LastUin int64 `json:"LastUin"`
MemberList []struct {
Age int `json:"Age"`
AutoRemark string `json:"AutoRemark"`
@@ -396,7 +396,7 @@ type GroupMemberList struct {
JoinTime int `json:"JoinTime"`
LastSpeakTime int `json:"LastSpeakTime"`
MemberLevel int `json:"MemberLevel"`
- MemberUin int `json:"MemberUin"`
+ MemberUin int64 `json:"MemberUin"`
Memo string `json:"Memo"`
NickName string `json:"NickName"`
ShowName string `json:"ShowName"`
@@ -409,7 +409,7 @@ type GroupMemberList struct {
type FriendList struct {
FriendCount int `json:"Friend_count"`
Friendlist []struct {
- FriendUin int `json:"FriendUin"`
+ FriendUin int64 `json:"FriendUin"`
IsRemark bool `json:"IsRemark"`
NickName string `json:"NickName"`
OnlineStr string `json:"OnlineStr"`
@@ -426,8 +426,8 @@ type GroupList struct {
Count int `json:"Count"`
NextToken string `json:"NextToken"`
TroopList []struct {
- GroupID int `json:"GroupId"`
- GroupMemberCount int `json:"GroupMemberCount"`
+ GroupID int64 `json:"GroupId"`
+ GroupMemberCount int64 `json:"GroupMemberCount"`
GroupName string `json:"GroupName"`
GroupNotice string `json:"GroupNotice"`
GroupOwner int64 `json:"GroupOwner"`
@@ -457,7 +457,7 @@ type UserInfo struct {
Qzone int `json:"qzone"`
Realname string `json:"realname"`
Smartname string `json:"smartname"`
- Uin int `json:"uin"`
+ Uin int64 `json:"uin"`
} `json:"data"`
Default int `json:"default"`
Message string `json:"message"`
From b8542c87de8cf77fbfeac4cbd607c023cd9bc379 Mon Sep 17 00:00:00 2001
From: mcoo <2435932516@qq.com>
Date: Sun, 23 May 2021 16:22:32 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E6=8D=B7?=
=?UTF-8?q?=E5=8F=91=E4=BF=A1=E6=81=AF=E7=9A=84=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 77bd0b9..c2ae93d 100644
--- a/README.md
+++ b/README.md
@@ -36,4 +36,5 @@
20210427 修复SocketIO数据畸形的问题,添加群上传功能
20210428 添加内置session 相关内容看Wiki
20210512 packet现在修改为传递指针,请注意
+20210523 添加快捷发信息的函数
```