@@ -42,7 +42,7 @@ public final class GitHubReference extends MessageReceiverAdapter {
42
42
* The pattern(#123) used to determine whether a message is referencing an issue.
43
43
*/
44
44
static final Pattern ISSUE_REFERENCE_PATTERN =
45
- Pattern .compile ("#(?<%s>\\ d+ )" .formatted (ID_GROUP ));
45
+ Pattern .compile ("#(?<%s>\\ d{1,5} )" .formatted (ID_GROUP ));
46
46
private static final int ISSUE_OPEN = Color .green .getRGB ();
47
47
private static final int ISSUE_CLOSE = Color .red .getRGB ();
48
48
@@ -108,8 +108,9 @@ public void onMessageReceived(MessageReceivedEvent event) {
108
108
109
109
while (matcher .find ()) {
110
110
long defaultRepoId = config .getGitHubRepositories ().get (0 );
111
- findIssue (Integer .parseInt (matcher .group (ID_GROUP )), defaultRepoId )
112
- .ifPresent (issue -> embeds .add (generateReply (issue )));
111
+
112
+ int issueId = Integer .parseInt (matcher .group (ID_GROUP ));
113
+ findIssue (issueId , defaultRepoId ).ifPresent (issue -> embeds .add (generateReply (issue )));
113
114
}
114
115
115
116
replyBatchEmbeds (embeds , message , false );
@@ -148,6 +149,10 @@ MessageEmbed generateReply(GHIssue issue) throws UncheckedIOException {
148
149
String titleUrl = issue .getHtmlUrl ().toString ();
149
150
String description = issue .getBody ();
150
151
152
+ if (description != null && description .length () > MessageEmbed .DESCRIPTION_MAX_LENGTH ) {
153
+ description = "too long for preview, visit Github" ;
154
+ }
155
+
151
156
String labels = issue .getLabels ()
152
157
.stream ()
153
158
.map (GHLabel ::getName )
@@ -231,6 +236,10 @@ List<GHRepository> getRepositories() {
231
236
}
232
237
233
238
private boolean isAllowedChannelOrChildThread (MessageReceivedEvent event ) {
239
+ if (event .getChannelType () != ChannelType .TEXT ) {
240
+ return false ;
241
+ }
242
+
234
243
if (event .getChannelType ().isThread ()) {
235
244
ThreadChannel threadChannel = event .getChannel ().asThreadChannel ();
236
245
String rootChannel = threadChannel .getParentChannel ().getName ();
0 commit comments