Beispiel #1
0
        private void HandleMessage(JToken resultValue, List <QQNotifyEvent> events)
        {
            /*
             *  {
             *      "result": [
             *          {
             *              "poll_type": "message",
             *              "value": {
             *                  "content": [
             *                      [
             *                          "font",
             *                          {
             *                              "color": "000000",
             *                              "name": "微软雅黑",
             *                              "size": 10,
             *                              "style": [
             *                                  0,
             *                                  0,
             *                                  0
             *                              ]
             *                          }
             *                      ],
             *                      [
             *                          "face",
             *                          107
             *                      ],
             *                      "xxx",
             *                      [
             *                          "face",
             *                          107
             *                      ]
             *                  ],
             *                  "from_uin": 3219658576,
             *                  "msg_id": 1019,
             *                  "msg_type": 0,
             *                  "time": 1479178662,
             *                  "to_uin": 89009143
             *              }
             *          }
             *      ],
             *      "retcode": 0
             *  }
             */
            var msg = resultValue.ToObject <FriendMessage>();

            msg.Friend = Store.GetOrAddFriendByUin(msg.FromUin, u =>
            {
                events.Add(QQNotifyEvent.CreateEvent(QQNotifyEventType.NeedUpdateFriends));
                return(new QQFriend()
                {
                    Uin = u
                });
            });
            msg.Contents = ContentFatory.ParseContents(resultValue["content"].ToJArray());

            events.Add(QQNotifyEvent.CreateEvent(QQNotifyEventType.ChatMsg, msg));
        }
Beispiel #2
0
        private void HandleGroupMessage(JToken resultValue, List <QQNotifyEvent> events)
        {
            /*
             *   {
             *      "result": [
             *          {
             *              "poll_type": "group_message",
             *              "value": {
             *                  "content": [
             *                      [
             *                          "font",
             *                          {
             *                              "color": "000000",
             *                              "name": "微软雅黑",
             *                              "size": 10,
             *                              "style": [
             *                                  0,
             *                                  0,
             *                                  0
             *                              ]
             *                          }
             *                      ],
             *                      "。。。"
             *                  ],
             *                  "from_uin": 3258316418,
             *                  "group_code": 3258316418,
             *                  "msg_id": 18537,
             *                  "msg_type": 0,
             *                  "send_uin": 2515522700,
             *                  "time": 1479175440,
             *                  "to_uin": 89009143
             *              }
             *          }
             *      ],
             *      "retcode": 0
             *  }
             */

            var msg = resultValue.ToObject <GroupMessage>();

            msg.Group = Store.GetOrAddGroupByGid(msg.GroupCode, u =>
            {
                events.Add(QQNotifyEvent.CreateEvent(QQNotifyEventType.NeedUpdateGroups));
                return(new QQGroup {
                    Gid = u
                });
            }); // 此处的GroupCode实际上是Group的gid
            msg.Contents = ContentFatory.ParseContents(resultValue["content"].ToJArray());

            events.Add(QQNotifyEvent.CreateEvent(QQNotifyEventType.ChatMsg, msg));
        }
Beispiel #3
0
        private Message HandleMessage(JToken resultValue)
        {
            /*
             *  {
             *      "result": [
             *          {
             *              "poll_type": "message",
             *              "value": {
             *                  "content": [
             *                      [
             *                          "font",
             *                          {
             *                              "color": "000000",
             *                              "name": "微软雅黑",
             *                              "size": 10,
             *                              "style": [
             *                                  0,
             *                                  0,
             *                                  0
             *                              ]
             *                          }
             *                      ],
             *                      [
             *                          "face",
             *                          107
             *                      ],
             *                      "xxx",
             *                      [
             *                          "face",
             *                          107
             *                      ]
             *                  ],
             *                  "from_uin": 3219658576,
             *                  "msg_id": 1019,
             *                  "msg_type": 0,
             *                  "time": 1479178662,
             *                  "to_uin": 89009143
             *              }
             *          }
             *      ],
             *      "retcode": 0
             *  }
             */
            var msg = resultValue.ToObject <Message>();

            msg.Type     = MessageType.Friend;
            msg.Contents = ContentFatory.ParseContents(resultValue["content"].ToJArray());
            return(msg);
        }
Beispiel #4
0
        private Message HandleGroupMessage(JToken resultValue)
        {
            /*
             *   {
             *      "result": [
             *          {
             *              "poll_type": "group_message",
             *              "value": {
             *                  "content": [
             *                      [
             *                          "font",
             *                          {
             *                              "color": "000000",
             *                              "name": "微软雅黑",
             *                              "size": 10,
             *                              "style": [
             *                                  0,
             *                                  0,
             *                                  0
             *                              ]
             *                          }
             *                      ],
             *                      "。。。"
             *                  ],
             *                  "from_uin": 3258316418,
             *                  "group_code": 3258316418,
             *                  "msg_id": 18537,
             *                  "msg_type": 0,
             *                  "send_uin": 2515522700,
             *                  "time": 1479175440,
             *                  "to_uin": 89009143
             *              }
             *          }
             *      ],
             *      "retcode": 0
             *  }
             */
            var msg = resultValue.ToObject <Message>();

            msg.Type     = MessageType.Group;
            msg.Contents = ContentFatory.ParseContents(resultValue["content"].ToJArray());
            return(msg);
        }