Пример #1
0
        /// <summary>
        /// 获得群成员列表
        /// !不可靠操作 请在成功获取后缓存 不要重复调用
        /// </summary>
        /// <param name="groupuin">群号</param>
        /// <returns>群列表</returns>
        public List <JsonModel.QQUser> getGroupMemberList(long groupuin)
        {
            long lastuin = 1;

            JsonModel.GroupMemberListRet data_get = new JsonModel.GroupMemberListRet();
            List <JsonModel.QQUser>      gplist   = new List <JsonModel.QQUser>();

            do
            {
                JsonModel.GetListReq reqdata = new JsonModel.GetListReq()
                {
                    GroupUin  = groupuin,
                    LastUin   = lastuin,
                    NextToken = ""
                };
                string json = System.Text.Json.JsonSerializer.Serialize(reqdata);
                //logger("debug_listgroup_reqjson", json);
                logger("debug_listgroup_step", "Requesting iotbot server...");
                string str = LuaApiCaller("GetGroupUserList", json);
                logger("debug_listgroup_step", "End requesting iotbot server. Done.");
                //logger("debug_listgroup_retjson", str);
                if (str == null || str.Length < 7)
                {
                    logger("debug_listgroup_warn", "Failure: Fail to fetch member list. Try again...");
                    Thread.Sleep(1000);
                    continue;
                }
                data_get = System.Text.Json.JsonSerializer.Deserialize <JsonModel.GroupMemberListRet>(str);
                logger("debug_listgroup_step", "Check for dumplicate items...");
                if (data_get.MemberList != null)
                {
                    foreach (JsonModel.QQUser qu in data_get.MemberList)
                    {
                        bool match = false;
                        foreach (QQUser qq in gplist)
                        {
                            if (qq.Equals(qu))
                            {
                                match = true;
                                logger("debug_listgroup_step", "HIT  " + qu.MemberUin);
                                break;
                            }
                        }
                        if (!match)
                        {
                            gplist.Add(qu);
                        }
                    }
                }

                lastuin = data_get.LastUin;
                if (lastuin > 0)
                {
                    logger("debug_listgroup_step", "List not complete. Wait 1 sec(s) to fetch next part.");
                    Thread.Sleep(1500);
                }
            } while (lastuin > 0);
            return(gplist);
        }
Пример #2
0
        /// <summary>
        /// 获得当前帐号所加入的群列表
        /// </summary>
        /// <returns></returns>
        public List <JsonModel.Group> getGroupList()
        {
            string nexttoken = "";

            JsonModel.GroupListRet data_get = new JsonModel.GroupListRet();
            List <JsonModel.Group> gplist   = new List <JsonModel.Group>();

            do
            {
                JsonModel.GetListReq reqdata = new JsonModel.GetListReq()
                {
                    GroupUin  = 0,
                    LastUin   = 0,
                    NextToken = nexttoken
                };
                string json = System.Text.Json.JsonSerializer.Serialize(reqdata);
                logger("debug_listgroup_reqjson", json);
                logger("debug_listgroup_step", "Requesting iotbot server...");
                string str = LuaApiCaller("GetGroupList", json);
                logger("debug_listgroup_step", "End requesting iotbot server. Done.");
                logger("debug_listgroup_retjson", str);
                if (str == null)
                {
                    continue;
                }

                data_get = System.Text.Json.JsonSerializer.Deserialize <JsonModel.GroupListRet>(str);
                if (data_get == null)
                {
                    continue;
                }

                gplist.AddRange(data_get.TroopList);
                nexttoken = data_get.NextToken;
            } while (nexttoken.Length > 0);
            return(gplist);
        }