Inheritance: QQStranger
Exemplo n.º 1
0
 public void AddMemeber(QQDiscuzMember user)
 {
     Members.Add(user);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 处理讨论组信息
        /// </summary>
        /// <param name="pollData"></param>
        /// <returns></returns>
        public QQNotifyEvent ProcessDiscuzMsg(JObject pollData)
        {
            try
            {
                var store = Context.Store;

                var msg = new QQMsg();
                var fromUin = pollData["send_uin"].ToObject<long>();
                var did = pollData["did"].ToObject<long>();

                msg.ParseContentList(JsonConvert.SerializeObject(pollData["content"]));
                msg.Type = QQMsgType.DISCUZ_MSG;
                msg.Discuz = store.GetDiscuzByDid(did);
                msg.To = Context.Account;
                var ticks = pollData["time"].ToObject<long>() * 1000;
                msg.Date = ticks > DateTime.MaxValue.Ticks ? DateTime.Now : new DateTime(ticks);

                if (msg.Discuz == null)
                {
                    var discuz = new QQDiscuz();
                    discuz.Did = did;
                    store.AddDiscuz(discuz);
                    msg.Discuz = store.GetDiscuzByDid(did);

                    var discuzModule = Context.GetModule<DiscuzModule>(QQModuleType.DISCUZ);
                    discuzModule.GetDiscuzInfo(discuz, null);
                }
                msg.From = msg.Discuz.GetMemberByUin(fromUin);

                if (msg.From == null)
                {
                    var member = new QQDiscuzMember { Uin = fromUin };
                    msg.From = member;
                    msg.Discuz.Members.Add(member);
                    // 获取用户信息
                    var userModule = Context.GetModule<UserModule>(QQModuleType.USER);
                    userModule.GetUserInfo(member, null);
                }
                return new QQNotifyEvent(QQNotifyEventType.CHAT_MSG, msg);
            }
            catch (Exception ex)
            {
                return new QQNotifyEvent(QQNotifyEventType.NET_ERROR, ex);
            }
        }
Exemplo n.º 3
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;
            if (json["retcode"].ToString() == "0")
            {
                JObject result = json["result"].ToObject<JObject>();

                //result/info
                JObject info = result["info"].ToObject<JObject>();
                discuz.Name = info["discu_name"].ToString();
                discuz.Owner = info["discu_owner"].ToObject<long>();

                //result/mem_list
                JArray memlist = result["mem_info"].ToObject<JArray>();
                foreach (JToken t in memlist)
                {
                    JObject memjson = t.ToObject<JObject>();
                    QQDiscuzMember member = discuz.GetMemberByUin(memjson["uin"].ToObject<long>());
                    if (member == null)
                    {
                        member = new QQDiscuzMember();
                        discuz.AddMemeber(member);
                    }
                    member.Uin = memjson["uin"].ToObject<long>();
                    member.QQ = memjson["uin"].ToObject<long>();	//这里有用户真实的QQ号
                    member.Nickname = memjson["nick"].ToString();
                    member.Discuz = discuz;
                }

                // 消除所有成员状态,如果不在线的,webqq是不会返回的。
                discuz.ClearStatus();
                //result/mem_status
                JArray statlist = result["mem_status"].ToObject<JArray>();
                foreach (JToken t in statlist)
                {
                    // 下面重新设置最新状态
                    JObject statjson = t.ToObject<JObject>();
                    QQUser member = discuz.GetMemberByUin(statjson["uin"].ToObject<long>());
                    if (statjson["client_type"] != null && member != null)
                    {
                        member.ClientType = QQClientType.ValueOfRaw(statjson["client_type"].ToObject<int>());
                        member.Status = QQStatus.ValueOfRaw(statjson["status"].ToString());
                    }
                }

                //result/mem_info
                JArray infolist = result["mem_info"].ToObject<JArray>();
                foreach (JToken t in infolist)
                {
                    JObject infojson = t.ToObject<JObject>();
                    QQUser member = discuz.GetMemberByUin(infojson["uin"].ToObject<long>());
                    member.Nickname = infojson["nick"].ToString();
                }

                NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));
            }
        }