Repository navigation
Expand file tree
/
Copy pathBaseInterActionEvent.java
More file actions
77 lines (63 loc) · 1.99 KB
/
Copy pathBaseInterActionEvent.java
File metadata and controls
77 lines (63 loc) · 1.99 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package io.github.kloping.qqbot.impl;
import com.alibaba.fastjson.JSONObject;
import io.github.kloping.qqbot.api.SendAble;
import io.github.kloping.qqbot.api.event.InterActionEvent;
import io.github.kloping.qqbot.entities.Bot;
import io.github.kloping.qqbot.entities.qqpd.InterAction;
import io.github.kloping.qqbot.entities.qqpd.message.RawMessage;
import io.github.kloping.qqbot.http.data.Result;
/**
* @author github.kloping
*/
public class BaseInterActionEvent implements InterActionEvent {
public BaseInterActionEvent(Bot bot, JSONObject metaData) {
this.metaData = metaData;
interAction = metaData.toJavaObject(InterAction.class);
interAction.setBot(bot);
}
private JSONObject metaData;
private InterAction interAction;
@Override
public Result send(String text) {
return getInterAction().send(text);
}
@Override
public Result send(String text, RawMessage message) {
return getInterAction().send(text, message);
}
@Override
public Result send(SendAble msg) {
return getInterAction().send(msg);
}
@Override
public JSONObject getMetadata() {
return metaData;
}
@Override
public Bot getBot() {
return getInterAction().getBot();
}
@Override
public Integer getChatType() {
return getInterAction().getChatType();
}
@Override
public InterAction getInterAction() {
return interAction;
}
@Override
public void response(int code) {
getBot().restApi.respondInteraction(getInterAction().getId(), code);
}
@Override
public String toString() {
return String.format("InterActionEvent [button %s(%s)] from %s"
, getInterAction().getData().getResolved().getButton_data()
, getInterAction().getData().getResolved().getButton_id()
, getInterAction().getCid());
}
@Override
public String getId() {
return getMetadata().get("id").toString();
}
}