@@ -42,7 +42,7 @@ public final class GitHubReference extends MessageReceiverAdapter {
4242 * The pattern(#123) used to determine whether a message is referencing an issue.
4343 */
4444 static final Pattern ISSUE_REFERENCE_PATTERN =
45- Pattern .compile ("#(?<%s>\\ d+ )" .formatted (ID_GROUP ));
45+ Pattern .compile ("#(?<%s>\\ d{1,5} )" .formatted (ID_GROUP ));
4646 private static final int ISSUE_OPEN = Color .green .getRGB ();
4747 private static final int ISSUE_CLOSE = Color .red .getRGB ();
4848
@@ -108,8 +108,9 @@ public void onMessageReceived(MessageReceivedEvent event) {
108108
109109 while (matcher .find ()) {
110110 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 )));
113114 }
114115
115116 replyBatchEmbeds (embeds , message , false );
@@ -148,6 +149,10 @@ MessageEmbed generateReply(GHIssue issue) throws UncheckedIOException {
148149 String titleUrl = issue .getHtmlUrl ().toString ();
149150 String description = issue .getBody ();
150151
152+ if (description != null && description .length () > MessageEmbed .DESCRIPTION_MAX_LENGTH ) {
153+ description = "too long for preview, visit Github" ;
154+ }
155+
151156 String labels = issue .getLabels ()
152157 .stream ()
153158 .map (GHLabel ::getName )
@@ -231,6 +236,10 @@ List<GHRepository> getRepositories() {
231236 }
232237
233238 private boolean isAllowedChannelOrChildThread (MessageReceivedEvent event ) {
239+ if (event .getChannelType () != ChannelType .TEXT ) {
240+ return false ;
241+ }
242+
234243 if (event .getChannelType ().isThread ()) {
235244 ThreadChannel threadChannel = event .getChannel ().asThreadChannel ();
236245 String rootChannel = threadChannel .getParentChannel ().getName ();
0 commit comments