Skip to content

Commit 32f95f3

Browse files
committed
v1.5.1-L3 fix bug #27;
初步支持消息列表(好友)事件; 完善新版emoji 新增超级表情emoji;
1 parent 86f50eb commit 32f95f3

29 files changed

+516
-38
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
logs/*
12
temp*
23
# Project exclude paths
34
src/test/java/temp/gs/**
@@ -9,7 +10,6 @@ temp.json
910
temp.http
1011
bot-qqpd-java.iml
1112
test_temp.java
12-
logs
1313
src/test/java/temp/*
1414
/src/test/java/test_temp_public.java
1515
/src/test/java/test_temp_private.java

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.kloping</groupId>
88
<artifactId>bot-qqpd-java</artifactId>
9-
<version>1.5.1-Beta3</version>
9+
<version>1.5.1-L3</version>
1010

1111
<packaging>jar</packaging>
1212
<name>bot-qqpd-java</name>

src/main/java/io/github/kloping/qqbot/api/event/Event.java

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public interface Event {
2323
*/
2424
Bot getBot();
2525

26+
/**
27+
* 事件id
28+
*
29+
* @return
30+
*/
31+
String getId();
32+
2633
default String getClassName() {
2734
return this.getClass().getSimpleName();
2835
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.github.kloping.qqbot.api.v2;
2+
3+
/**
4+
* @author github.kloping
5+
*/
6+
public interface FriendAdd extends FriendEvent {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.kloping.qqbot.api.v2;
2+
3+
import io.github.kloping.qqbot.entities.qqpd.v2.Contact;
4+
import io.github.kloping.qqbot.entities.qqpd.v2.Friend;
5+
6+
/**
7+
* @author github.kloping
8+
*/
9+
public interface FriendEvent extends V2Event {
10+
/**
11+
* get friend
12+
*
13+
* @return
14+
*/
15+
Friend getFriend();
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.github.kloping.qqbot.api.v2;
2+
3+
import io.github.kloping.qqbot.entities.qqpd.v2.Friend;
4+
5+
/**
6+
* @author github.kloping
7+
*/
8+
public interface FriendMessageEvent extends FriendEvent, MessageV2Event {
9+
@Override
10+
Friend getSender();
11+
12+
@Override
13+
Friend getSubject();
14+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package io.github.kloping.qqbot.api.v2;
22

3-
import io.github.kloping.qqbot.api.event.Event;
43
import io.github.kloping.qqbot.entities.qqpd.v2.Group;
54

65
/**
76
* @author github.kloping
87
*/
9-
public interface GroupEvent extends Event, V2Event {
8+
public interface GroupEvent extends V2Event {
109
Group getGroup();
1110

1211
String getGroupId();
1312

1413
default String getGroupOpenId() {
1514
return getGroupId();
1615
}
16+
17+
@Override
18+
default String getOpenId() {
19+
return getGroupOpenId();
20+
}
1721
}

src/main/java/io/github/kloping/qqbot/api/v2/GroupMessageEvent.java

-8
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@ public interface GroupMessageEvent extends GroupEvent, MessageEvent<Contact,Grou
1515
* @return
1616
*/
1717
Group getSubject();
18-
19-
20-
/**
21-
* 设置消息序列号并返回原序列号
22-
* @param seq
23-
* @return
24-
*/
25-
Integer setMsgSeq(Integer seq);
2618
}

src/main/java/io/github/kloping/qqbot/api/v2/MessageV2Event.java

+8
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ public interface MessageV2Event extends Event, Sender, V2Event {
4242
* @return
4343
*/
4444
Contact getSubject();
45+
46+
47+
/**
48+
* 设置消息序列号并返回原序列号
49+
* @param seq
50+
* @return
51+
*/
52+
Integer setMsgSeq(Integer seq);
4553
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
package io.github.kloping.qqbot.api.v2;
22

3+
import io.github.kloping.qqbot.api.event.Event;
4+
35
/**
4-
* 机器人群聊事件
5-
*
66
* @author github.kloping
77
*/
8-
public interface V2Event {
9-
/**
10-
* 事件id
11-
*
12-
* @return
13-
*/
14-
String getId();
15-
8+
public interface V2Event extends Event {
169
/**
17-
* 事情群聊openid
18-
*
19-
* @return
10+
* 所处环境 openid 可能是 user openid 或 group openid
11+
* @return
2012
*/
21-
String getGroupOpenId();
13+
String getOpenId();
2214
}

src/main/java/io/github/kloping/qqbot/entities/ex/At.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@ public class At implements SendAble {
1515
public static final String MEMBER_TYPE = "member";
1616
public static final String CHANNEL_TYPE = "channel";
1717

18-
private String type;
18+
private String type = "member";
1919
private String targetId;
2020

2121
public At(String type, String targetId) {
2222
this.type = type;
2323
this.targetId = targetId;
2424
}
2525

26+
public At(String targetId) {
27+
this.targetId = targetId;
28+
}
29+
2630
@Override
2731
public String toString() {
2832
if (CHANNEL_TYPE.equals(type)) {
2933
return "<#" + targetId + ">";
3034
} else if (MEMBER_TYPE.equals(type)) {
31-
return "<@!" + targetId + ">";
35+
return String.format("<qqbot-at-user id=\"%s\" />", targetId);
3236
} else return "@";
3337
}
3438

src/main/java/io/github/kloping/qqbot/entities/ex/enums/EnvType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author github.kloping
77
*/
88
public enum EnvType {
9-
GUILD, GROUP, GROUP_USER
9+
GUILD, GROUP, GROUP_USER, USER
1010
}

src/main/java/io/github/kloping/qqbot/entities/qqpd/data/Emoji.java

+51-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,56 @@ public class Emoji implements SendAble {
285285
public static final Emoji 你真棒棒 = new Emoji(1, 346, "你真棒棒");
286286
public static final Emoji 大展宏兔 = new Emoji(1, 347, "大展宏兔");
287287
public static final Emoji 福萝卜 = new Emoji(1, 348, "福萝卜");
288+
public static final Emoji 亲亲 = new Emoji(1, 360, "亲亲");
289+
public static final Emoji 狗狗笑哭 = new Emoji(1, 361, "狗狗笑哭");
290+
public static final Emoji 好兄弟 = new Emoji(1, 362, "好兄弟");
291+
public static final Emoji 狗狗可怜 = new Emoji(1, 363, "狗狗可怜");
292+
public static final Emoji 超级赞 = new Emoji(1, 364, "超级赞");
293+
public static final Emoji 狗狗生气 = new Emoji(1, 365, "狗狗生气");
294+
public static final Emoji 芒狗 = new Emoji(1, 366, "芒狗");
295+
public static final Emoji 狗狗疑问 = new Emoji(1, 367, "狗狗疑问");
296+
public static final Emoji 奥特笑哭 = new Emoji(1, 368, "奥特笑哭");
297+
public static final Emoji 彩虹 = new Emoji(1, 369, "彩虹");
298+
public static final Emoji 祝贺 = new Emoji(1, 370, "祝贺");
299+
public static final Emoji 冒泡 = new Emoji(1, 371, "冒泡");
300+
public static final Emoji 气呼呼 = new Emoji(1, 372, "气呼呼");
301+
public static final Emoji = new Emoji(1, 373, "忙");
302+
public static final Emoji 波波流泪 = new Emoji(1, 374, "波波流泪");
303+
public static final Emoji 超级鼓掌 = new Emoji(1, 375, "超级鼓掌");
304+
public static final Emoji 跺脚 = new Emoji(1, 376, "跺脚");
305+
public static final Emoji = new Emoji(1, 377, "嗨");
306+
public static final Emoji 企鹅笑哭 = new Emoji(1, 378, "企鹅笑哭");
307+
public static final Emoji 企鹅流泪 = new Emoji(1, 379, "企鹅流泪");
308+
public static final Emoji 真棒 = new Emoji(1, 380, "真棒");
309+
public static final Emoji 路过 = new Emoji(1, 381, "路过");
310+
public static final Emoji emo = new Emoji(1, 382, "emo");
311+
public static final Emoji 企鹅爱心 = new Emoji(1, 383, "企鹅爱心");
312+
public static final Emoji 晚安 = new Emoji(1, 384, "晚安");
313+
public static final Emoji 太气了 = new Emoji(1, 385, "太气了");
314+
public static final Emoji 呜呜呜 = new Emoji(1, 386, "呜呜呜");
315+
public static final Emoji 太好笑 = new Emoji(1, 387, "太好笑");
316+
public static final Emoji 太头疼 = new Emoji(1, 388, "太头疼");
317+
public static final Emoji 太赞了 = new Emoji(1, 389, "太赞了");
318+
public static final Emoji 太头秃 = new Emoji(1, 390, "太头秃");
319+
public static final Emoji 太沧桑 = new Emoji(1, 391, "太沧桑");
320+
public static final Emoji 狼狗 = new Emoji(1, 396, "狼狗");
321+
public static final Emoji 抛媚眼 = new Emoji(1, 397, "抛媚眼");
322+
public static final Emoji 超级ok = new Emoji(1, 398, "超级ok");
323+
public static final Emoji tui = new Emoji(1, 399, "tui");
324+
public static final Emoji 快乐 = new Emoji(1, 400, "快乐");
325+
public static final Emoji 超级旋转 = new Emoji(1, 401, "超级旋转");
326+
public static final Emoji 别说话 = new Emoji(1, 402, "别说话");
327+
public static final Emoji 出去玩 = new Emoji(1, 403, "出去玩");
328+
public static final Emoji 闪亮登场 = new Emoji(1, 404, "闪亮登场");
329+
public static final Emoji 好运来 = new Emoji(1, 405, "好运来");
330+
public static final Emoji 姐是女王 = new Emoji(1, 406, "姐是女王");
331+
public static final Emoji 我听听 = new Emoji(1, 407, "我听听");
332+
public static final Emoji 臭美 = new Emoji(1, 408, "臭美");
333+
public static final Emoji 送你花花 = new Emoji(1, 409, "送你花花");
334+
public static final Emoji 么么哒 = new Emoji(1, 410, "么么哒");
335+
public static final Emoji 一起嗨 = new Emoji(1, 411, "一起嗨");
336+
public static final Emoji 开心 = new Emoji(1, 412, "开心");
337+
public static final Emoji 摇起来 = new Emoji(1, 413, "摇起来");
288338
/**
289339
* 以上是qq emoji
290340
* <hr>
@@ -335,7 +385,7 @@ public class Emoji implements SendAble {
335385
public static final Emoji 汗2 = new Emoji(2, 128531, "😓 汗");
336386
public static final Emoji 失落 = new Emoji(2, 128532, "😔 失落");
337387
public static final Emoji 飞吻2 = new Emoji(2, 128536, "😘 飞吻");
338-
public static final Emoji 亲亲 = new Emoji(2, 128538, "😚 亲亲");
388+
public static final Emoji 亲亲2 = new Emoji(2, 128538, "😚 亲亲");
339389
public static final Emoji 淘气 = new Emoji(2, 128540, "😜 淘气");
340390
public static final Emoji 吐舌 = new Emoji(2, 128541, "😝 吐舌");
341391
public static final Emoji 大哭2 = new Emoji(2, 128557, "😭 大哭");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package io.github.kloping.qqbot.entities.qqpd.v2;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.JSONObject;
5+
import io.github.kloping.qqbot.api.SendAble;
6+
import io.github.kloping.qqbot.api.SenderAndCidMidGetter;
7+
import io.github.kloping.qqbot.api.SenderV2;
8+
import io.github.kloping.qqbot.entities.ex.enums.EnvType;
9+
import io.github.kloping.qqbot.entities.qqpd.Channel;
10+
import io.github.kloping.qqbot.entities.qqpd.message.RawMessage;
11+
import io.github.kloping.qqbot.http.BaseV2;
12+
import io.github.kloping.qqbot.http.data.Result;
13+
import io.github.kloping.qqbot.http.data.V2MsgData;
14+
import io.github.kloping.qqbot.http.data.V2Result;
15+
import lombok.EqualsAndHashCode;
16+
17+
/**
18+
* @author github.kloping
19+
*/
20+
@EqualsAndHashCode(callSuper = true)
21+
public class Friend extends Contact implements SenderAndCidMidGetter, SenderV2 {
22+
public Friend(JSONObject mate) {
23+
super(mate);
24+
if (getMeta().containsKey("openid")) {
25+
String id = getMeta().getString("openid");
26+
this.setId(id);
27+
this.setOpenid(openid);
28+
} else {
29+
this.setId(this.getMeta().getString("id"));
30+
this.setOpenid(this.getMeta().getString("user_openid"));
31+
}
32+
}
33+
34+
@Override
35+
public Result<V2Result> send(String text) {
36+
V2MsgData data = new V2MsgData().setContent(text);
37+
return new Result<V2Result>(bot.userBaseV2.send(getOpenid(), JSON.toJSONString(data), Channel.SEND_MESSAGE_HEADERS));
38+
}
39+
40+
@Override
41+
public Result<V2Result> send(String text, RawMessage message) {
42+
return message.send(text);
43+
}
44+
45+
@Override
46+
public Result send(SendAble msg) {
47+
return msg.send(this);
48+
}
49+
50+
@Override
51+
public String getCid() {
52+
return getOpenid();
53+
}
54+
55+
@Override
56+
public EnvType getEnvType() {
57+
return EnvType.GROUP_USER;
58+
}
59+
60+
@Override
61+
public BaseV2 getV2() {
62+
return getBot().userBaseV2;
63+
}
64+
}

src/main/java/io/github/kloping/qqbot/impl/BaseChannelEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ public BaseChannelEvent(JSONObject jo, Bot bot) {
2222
public Channel getChannel() {
2323
return channel;
2424
}
25+
26+
@Override
27+
public String getId() {
28+
return getMetadata().get("id").toString();
29+
}
2530
}

src/main/java/io/github/kloping/qqbot/impl/BaseConnectedEvent.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public String getClassName() {
4141

4242
@Override
4343
public String toString() {
44-
return String.format("Bot(%s) Connected! By author kloping of bot-qqpd-java for version 1.5.1-Beta3", bot.getConfig().getAppid());
44+
return String.format("Bot(%s) Connected! By author kloping of bot-qqpd-java for version 1.5.1-L3", bot.getConfig().getAppid());
45+
}
46+
47+
@Override
48+
public String getId() {
49+
return getMetadata().get("id").toString();
4550
}
4651
}

src/main/java/io/github/kloping/qqbot/impl/BaseGuildUpdateEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public String getUnionWorldId() {
3131
public String toString() {
3232
return String.format("guild(%s) id(%s) info change", guild.getName(), guild.getId());
3333
}
34+
35+
@Override
36+
public String getId() {
37+
return getMetadata().get("id").toString();
38+
}
3439
}

src/main/java/io/github/kloping/qqbot/impl/BaseInterActionEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ public String toString() {
6868
, getInterAction().getData().getResolved().getButton_id()
6969
, getInterAction().getCid());
7070
}
71+
72+
@Override
73+
public String getId() {
74+
return getMetadata().get("id").toString();
75+
}
7176
}

src/main/java/io/github/kloping/qqbot/impl/BaseMemberRemoveEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public MemberWithGuildID getMember() {
3131
public String toString() {
3232
return String.format("member(%s) remove from %s", member.getNick(), guild.getName());
3333
}
34+
35+
@Override
36+
public String getId() {
37+
return getMetadata().get("id").toString();
38+
}
3439
}

src/main/java/io/github/kloping/qqbot/impl/BaseMemberUpdateEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ public MemberWithGuildID getMember() {
3232
public String toString() {
3333
return String.format("member(%s) in %s info change", member.getNick(), guild.getName());
3434
}
35+
36+
@Override
37+
public String getId() {
38+
return getMetadata().get("id").toString();
39+
}
3540
}

src/main/java/io/github/kloping/qqbot/impl/message/BaseMessageEvent.java

+5
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,9 @@ public MessageChain getMessage() {
126126
public void setFilter(Class<?>[] filters) {
127127
this.filters = filters;
128128
}
129+
130+
@Override
131+
public String getId() {
132+
return getRawMessage().getId();
133+
}
129134
}

0 commit comments

Comments
 (0)