// {"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]," "]}}]}
QQStore store = getContext().getStore();
QQMsg msg = new QQMsg();
long fromUin = pollData.getLong("from_uin");
long fromQQ = pollData.getLong("ruin"); // 真实QQ
int serviceType = pollData.getInt("service_type"); // Group:0,Discuss:1
long typeId = pollData.getLong("id"); // Group ID or Discuss ID
msg.parseContentList(pollData.getJSONArray("content").toString());
msg.setType(QQMsg.Type.SESSION_MSG);
msg.setTo(getContext().getAccount());
msg.setDate(new Date(pollData.getLong("time") * 1000));
QQUser user = store.getBuddyByUin(fromUin); // 首先看看是不是自己的好友
if (user != null) {
msg.setType(QQMsg.Type.BUDDY_MSG); // 是自己的好友
} else {
if (serviceType == 0) { // 是群成员
QQGroup group = store.getGroupByCode(typeId);
for (QQUser u : group.getMembers()) {
if (u.getUin() == fromUin) {
user = u;
break;
}
}
} else if (serviceType == 1) { // 是讨论组成员
QQDiscuz discuz = store.getDiscuzByDid(typeId);
for (QQUser u : discuz.getMembers()) {
if (u.getUin() == fromUin) {
user = u;
break;
}
}
} else {
user = store.getStrangerByUin(fromUin); // 看看陌生人列表中有木有
}
if (user == null) { // 还没有就新建一个陌生人,原理来说不应该这样。后面我就不知道怎么回复这消息了,但是消息是不能丢失的
user = new QQStranger();
user.setQQ(pollData.getLong("ruin"));
user.setUin(fromUin);
user.setNickname(pollData.getLong("ruin") + "");
store.addStranger((QQStranger)user);
}
}
user.setQQ(fromQQ); // 带上QQ号码
msg.setFrom(user);
return new QQNotifyEvent(QQNotifyEvent.Type.CHAT_MSG, msg);
}