Ejemplo n.º 1
0
        /// <summary>
        /// 获取群成员信息
        /// </summary>
        /// <param name="groupId">目标群</param>
        /// <param name="qqId">目标QQ</param>
        /// <param name="member">如果成功, 返回群成员信息</param>
        /// <param name="notCache">默认为 "Flase", 通常忽略本参数, 仅在必要的是否使用</param>
        /// <returns>成功返回 0, 失败返回 负数</returns>
        public int GetMemberInfo(long groupId, long qqId, out GroupMember member, bool notCache = false)
        {
            string result = CQP.CQ_getGroupMemberInfoV2(_authCode, groupId, qqId, notCache);

            if (string.IsNullOrEmpty(result))
            {
                member = null;
                return(-1000);
            }
            #region --其它_转换_文本到群成员信息--
            member = new GroupMember();
            UnPack unpack = new UnPack(Convert.FromBase64String(result));
            member.GroupId                  = unpack.GetInt64();
            member.QQId                     = unpack.GetInt64();
            member.Nick                     = unpack.GetString(Encoding.GetEncoding("GB18030"));
            member.Card                     = unpack.GetString(Encoding.GetEncoding("GB18030"));
            member.Sex                      = (Sex)unpack.GetInt32();
            member.Age                      = unpack.GetInt32();
            member.Area                     = unpack.GetString(Encoding.GetEncoding("GB18030"));
            member.JoiningTime              = NativeConvert.FotmatUnixTime(unpack.GetInt32().ToString());
            member.LastDateTime             = NativeConvert.FotmatUnixTime(unpack.GetInt32().ToString());
            member.Level                    = unpack.GetString(Encoding.GetEncoding("GB18030"));
            member.PermitType               = (PermitType)unpack.GetInt32();
            member.BadRecord                = unpack.GetInt32() == 1;
            member.SpecialTitle             = unpack.GetString(Encoding.GetEncoding("GB18030"));
            member.SpecialTitleDurationTime = NativeConvert.FotmatUnixTime(unpack.GetInt32().ToString());
            member.CanModifiedCard          = unpack.GetInt32() == 1;
            #endregion
            return(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取群列表
        /// </summary>
        /// <param name="groups"></param>
        /// <returns></returns>
        public int GetGroupList(out List <Group> groups)
        {
            string result = CQP.CQ_getGroupList(_authCode);

            if (string.IsNullOrEmpty(result))
            {
                groups = null;
                return(-1000);
            }
            groups = new List <Group> ();
            #region --其他_转换_文本到群列表信息a--
            UnPack unpack = new UnPack(Convert.FromBase64String(result));
            for (int i = 0, len = unpack.GetInt32(); i < len; i++)
            {
                if (unpack.OverLength <= 0)
                {
                    groups = null;
                    return(-1000);
                }
                #region --其他_转换_ansihex到群信息--
                UnPack temp  = new UnPack(unpack.GetToken());
                Group  group = new Group();
                group.Id   = temp.GetInt64();
                group.Name = temp.GetString(Encoding.GetEncoding("GB18030"));
                groups.Add(group);
                #endregion
            }
            #endregion
            return(0);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取QQ信息
        /// </summary>
        /// <param name="qqId">目标QQ</param>
        /// <param name="qqInfo">返回QQ信息, 若获取失败, 返回null</param>
        /// <param name="notCache">不使用缓存, 默认为"False",通常忽略本参数,仅在必要时使用</param>
        /// <returns></returns>
        public int GetQQInfo(long qqId, out QQ qqInfo, bool notCache = false)
        {
            string result = CQP.CQ_getStrangerInfo(_authCode, qqId, notCache);

            if (string.IsNullOrEmpty(result))
            {
                qqInfo = null;
                return(-1000);
            }
            UnPack unpack = new UnPack(Convert.FromBase64String(result));

            qqInfo      = new QQ();
            qqInfo.Id   = unpack.GetInt64();
            qqInfo.Nick = unpack.GetString(Encoding.GetEncoding("GB18030"));
            qqInfo.Sex  = (Sex)unpack.GetInt32();
            qqInfo.Age  = unpack.GetInt32();
            return(0);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取群成员列表
        /// </summary>
        /// <param name="groupId">目标群</param>
        /// <param name="memberInfos">如果成功,返回群成员列表</param>
        /// <returns>成功返回 0, 失败返回 负数</returns>
        public int GetMemberList(long groupId, out List <GroupMember> memberInfos)
        {
            string result = CQP.CQ_getGroupMemberList(_authCode, groupId);

            if (string.IsNullOrEmpty(result))
            {
                memberInfos = null;
                return(-1000);
            }
            #region --其他_转换_文本到群成员列表信息a--
            UnPack unpack = new UnPack(Convert.FromBase64String(result));
            memberInfos = new List <GroupMember> ();
            for (int i = 0, len = unpack.GetInt32(); i < len; i++)
            {
                if (unpack.OverLength <= 0)
                {
                    memberInfos = null;
                    return(-1000);
                }
                #region --其它_转换_ansihex到群成员信息--
                UnPack      temp   = new UnPack(unpack.GetToken()); //解析群成员信息
                GroupMember member = new GroupMember
                {
                    GroupId                  = temp.GetInt64(),
                    QQId                     = temp.GetInt64(),
                    Nick                     = temp.GetString(Encoding.GetEncoding("GB18030")),
                    Card                     = temp.GetString(Encoding.GetEncoding("GB18030")),
                    Sex                      = (Sex)temp.GetInt32(),
                    Age                      = temp.GetInt32(),
                    Area                     = temp.GetString(Encoding.GetEncoding("GB18030")),
                    JoiningTime              = NativeConvert.FotmatUnixTime(temp.GetInt32().ToString()),
                    LastDateTime             = NativeConvert.FotmatUnixTime(temp.GetInt32().ToString()),
                    Level                    = temp.GetString(Encoding.GetEncoding("GB18030")),
                    PermitType               = (PermitType)temp.GetInt32(),
                    BadRecord                = temp.GetInt32() == 1,
                    SpecialTitle             = temp.GetString(Encoding.GetEncoding("GB18030")),
                    SpecialTitleDurationTime = NativeConvert.FotmatUnixTime(temp.GetInt32().ToString()),
                    CanModifiedCard          = temp.GetInt32() == 1
                };
                #endregion
                memberInfos.Add(member);
            }
            #endregion
            return(0);
        }