예제 #1
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            //{"retcode":0,"result":{"dnamelist":[{"did":3536443553,"name":"\u8FD9\u662F\u6807\u9898"},
            //{"did":625885728,"name":""}],"dmasklist":[{"did":1000,"mask":0}]}}

            JObject json = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;
            if (json["retcode"].ToString() == "0")
            {
                JObject result = json["result"].ToObject<JObject>();
                JArray dizlist = result["dnamelist"].ToObject<JArray>();
                for (int i = 0; i < dizlist.Count; i++)
                {
                    QQDiscuz discuz = new QQDiscuz();
                    JObject dizjson = dizlist[i].ToObject<JObject>();
                    discuz.Did = dizjson["did"].ToObject<long>();
                    discuz.Name = dizjson["name"].ToString();
                    store.AddDiscuz(discuz);
                }
                NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));
            }
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            QQDiscuz other = (QQDiscuz)obj;

            if (Did != other.Did)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
 public IQQActionFuture GetDiscuzInfo(QQDiscuz discuz, QQActionListener listener)
 {
     return PushHttpAction(new GetDiscuzInfoAction(this.Context, listener, discuz));
 }
예제 #4
0
        /// <summary>
        /// 处理临时会话消息
        /// </summary>
        /// <param name="pollData"></param>
        /// <returns></returns>
        public QQNotifyEvent ProcessSessionMsg(JObject pollData)
        {
            // {"retcode":0,"result":[{"poll_type":"sess_message",
            // "value":{"msg_id":25144,"from_uin":167017143,"to_uin":1070772010,"msg_id2":139233,"msg_type":140,"reply_ip":176752037,"time":1365931836,"id":2581801127,"ruin":444674479,"service_type":1,
            // "flags":{"text":1,"pic":1,"file":1,"audio":1,"video":1},"content":[["font",{"size":9,"color":"000000","style":[0,0,0],"name":"Tahoma"}],"2\u8F7D3 ",["face",1]," "]}}]}
            try
            {
                var store = Context.Store;
                var msg = new QQMsg();
                var fromUin = pollData["from_uin"].ToObject<long>();
                var fromQQ = pollData["ruin"].ToObject<long>();// 真实QQ
                var serviceType = pollData["service_type"].ToObject<int>(); // Group:0,Discuss:1
                var typeId = pollData["id"].ToObject<long>(); // Group ID or Discuss ID

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

                QQUser user = store.GetBuddyByUin(fromUin); // 首先看看是不是自己的好友
                if (user != null)
                {
                    msg.Type = QQMsgType.BUDDY_MSG; // 是自己的好友
                }
                else
                {
                    if (serviceType == 0)
                    { // 是群成员
                        var group = store.GetGroupByCode(typeId);
                        if (group == null)
                        {
                            group = new QQGroup();
                            group.Code = typeId;
                            // 获取群信息
                            var groupModule = Context.GetModule<GroupModule>(QQModuleType.GROUP);
                            groupModule.GetGroupInfo(group, null);
                        }
                        foreach (QQGroupMember u in group.Members)
                        {
                            if (u.Uin == fromUin)
                            {
                                user = u;
                                break;
                            }
                        }
                    }
                    else if (serviceType == 1)
                    { // 是讨论组成员
                        var discuz = store.GetDiscuzByDid(typeId);
                        if (discuz == null)
                        {
                            discuz = new QQDiscuz { Did = typeId };

                            // 获取讨论组信息
                            var discuzModule = Context.GetModule<DiscuzModule>(QQModuleType.DISCUZ);
                            discuzModule.GetDiscuzInfo(discuz, null);
                        }


                        foreach (QQDiscuzMember u in discuz.Members)
                        {
                            if (u.Uin == fromUin)
                            {
                                user = u;
                                break;
                            }
                        }
                    }
                    else
                    {
                        user = store.GetStrangerByUin(fromUin); // 看看陌生人列表中有木有
                    }
                    if (user == null)
                    { // 还没有就新建一个陌生人,原理来说不应该这样。后面我就不知道怎么回复这消息了,但是消息是不能丢失的
                        user = new QQStranger
                        {
                            QQ = pollData["ruin"].ToObject<long>(),
                            Uin = fromUin,
                            Nickname = pollData["ruin"] + ""
                        };
                        store.AddStranger((QQStranger)user);

                        // 获取用户信息
                        var userModule = Context.GetModule<UserModule>(QQModuleType.USER);
                        userModule.GetStrangerInfo(user, null);
                    }
                }
                user.QQ = fromQQ; // 带上QQ号码
                msg.From = user;
                return new QQNotifyEvent(QQNotifyEventType.CHAT_MSG, msg);
            }
            catch (Exception ex)
            {
                return new QQNotifyEvent(QQNotifyEventType.NET_ERROR, ex);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        public GetDiscuzInfoAction(QQContext context, QQActionEventHandler listener, QQDiscuz discuz)
            : base(context, listener)
        {

            this.discuz = discuz;
        }
예제 #7
0
 public void DeleteDiscuz(QQDiscuz discuz)
 {
     _discuzMap.TryRemove(discuz.Did, out discuz);
 }
예제 #8
0
 public void AddDiscuz(QQDiscuz discuz)
 {
     _discuzMap[discuz.Did] = discuz;
 }
예제 #9
0
 public GetDiscuzInfoAction(IQQContext context, QQActionListener listener, QQDiscuz discuz)
     : base(context, listener)
 {
     this.discuz = discuz;
 }
예제 #10
0
파일: QQStore.cs 프로젝트: hhhaiai/iQQ.Net
 public void DeleteDiscuz(QQDiscuz discuz)
 {
     _discuzMap.Remove(discuz.Did);
 }
예제 #11
0
파일: QQStore.cs 프로젝트: hhhaiai/iQQ.Net
 public void AddDiscuz(QQDiscuz discuz)
 {
     _discuzMap.Add(discuz.Did, discuz, AddChoice.Update);
 }