forked from Together-Java/TJ-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageReceiver.java
More file actions
69 lines (62 loc) · 2.8 KB
/
MessageReceiver.java
File metadata and controls
69 lines (62 loc) · 2.8 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
package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import java.util.regex.Pattern;
/**
* Receives incoming Discord guild messages from channels matching a given pattern.
* <p>
* All message receivers have to implement this interface. For convenience, there is a
* {@link MessageReceiverAdapter} available that implemented most methods already. A new receiver
* can then be registered by adding it to {@link Features}.
* <p>
* <p>
* After registration, the system will notify a receiver whenever a new message was sent or an
* existing message was updated in any channel matching the {@link #getChannelNamePattern()} the bot
* is added to.
*/
public interface MessageReceiver extends Feature {
/**
* Retrieves the pattern matching the names of channels of which this receiver is interested in
* receiving sent messages from. Called by the core system once during the startup in order to
* register the receiver accordingly.
* <p>
* Changes on the pattern returned by this method afterwards will not be picked up.
*
* @return the pattern matching the names of relevant channels
*/
Pattern getChannelNamePattern();
/**
* Triggered by the core system whenever a new message was sent and received in a text channel
* of a guild the bot has been added to.
*
* @param event the event that triggered this, containing information about the corresponding
* message that was sent and received
*/
void onMessageReceived(MessageReceivedEvent event);
/**
* Triggered by the core system whenever an existing message was edited in a text channel of a
* guild the bot has been added to.
*
* @param event the event that triggered this, containing information about the corresponding
* message that was edited
*/
void onMessageUpdated(MessageUpdateEvent event);
/**
* Triggered by the core system whenever an existing message was deleted in a text channel of a
* guild the bot has been added to.
*
* @param event the event that triggered this, containing information about the corresponding
* message that was deleted
*/
void onMessageDeleted(MessageDeleteEvent event);
/**
* Triggered by the core system whenever a new reaction was added to a message in a text channel
* of a guild the bot has been added to.
*
* @param event the event that triggered this, containing information about the corresponding
* reaction that was added
*/
void onMessageReactionAdd(MessageReactionAddEvent event);
}