-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_onMessage.java
61 lines (56 loc) · 2.25 KB
/
test_onMessage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import io.github.kloping.qqbot.Starter;
import io.github.kloping.qqbot.api.message.MessageChannelReceiveEvent;
import io.github.kloping.qqbot.api.message.MessageDirectReceiveEvent;
import io.github.kloping.qqbot.api.message.MessageEvent;
import io.github.kloping.qqbot.entities.ex.At;
import io.github.kloping.qqbot.entities.ex.AtAll;
import io.github.kloping.qqbot.entities.ex.Image;
import io.github.kloping.qqbot.entities.ex.PlainText;
import io.github.kloping.qqbot.entities.ex.msg.MessageChain;
import io.github.kloping.qqbot.entities.qqpd.data.Emoji;
import io.github.kloping.qqbot.entities.qqpd.message.RawMessage;
import io.github.kloping.qqbot.impl.ListenerHost;
/**
* @author github.kloping
*/
public class test_onMessage {
public static void main(String[] args) throws Exception {
Starter starter = test_main.factory();
starter.run();
starter.registerListenerHost(new ListenerHost() {
@EventReceiver
private void event(MessageEvent event) {
RawMessage message = event.getRawMessage();
message.send("回复测试");
}
});
starter.registerListenerHost(new ListenerHost() {
@EventReceiver
public void onEvent(MessageEvent event) {
event.send("测试");
}
@EventReceiver
public void onEvent(MessageDirectReceiveEvent event) {
event.send("测试通过");
}
@EventReceiver
public void onMessage(MessageChannelReceiveEvent event) {
//消息类型遍历
MessageChain chain = event.getMessage();
chain.forEach((e) -> {
if (e instanceof Emoji) {
Emoji emoji = (Emoji) e;
} else if (e instanceof At) {
At at = (At) e;
} else if (e instanceof AtAll) {
AtAll atAll = (AtAll) e;
} else if (e instanceof Image) {
Image image = (Image) e;
} else if (e instanceof PlainText) {
PlainText plainText = (PlainText) e;
}
});
}
});
}
}