Skip to content

Commit

Permalink
Add mediators to ChatService.java and Messenger.java #123
Browse files Browse the repository at this point in the history
  • Loading branch information
pdolif committed Aug 9, 2022
1 parent 7fcbd51 commit 5182bd2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package i5.las2peer.services.socialBotManagerService.chat;

import com.fasterxml.jackson.annotation.JsonProperty;
import i5.las2peer.services.socialBotManagerService.chat.github.GitHubIssueMediator;
import i5.las2peer.services.socialBotManagerService.chat.github.GitHubPRMediator;

/**
* This enum lists all available messenger services. The string value has to
Expand All @@ -23,6 +25,12 @@ public enum ChatService {
@JsonProperty("Moodle Forum")
MOODLE_FORUM("Moodle Forum", MoodleForumMediator.class),

@JsonProperty("GitHub Issues")
GITHUB_ISSUES("GitHub Issues", GitHubIssueMediator.class),

@JsonProperty("GitHub Pull Requests")
GITHUB_PR("GitHub Pull Requests", GitHubPRMediator.class),

UNKNOWN("", null);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import javax.websocket.DeploymentException;

import i5.las2peer.services.socialBotManagerService.chat.*;
import i5.las2peer.services.socialBotManagerService.chat.xAPI.ChatStatement;
import i5.las2peer.services.socialBotManagerService.chat.github.GitHubAppHelper;
import i5.las2peer.services.socialBotManagerService.chat.github.GitHubIssueMediator;
import i5.las2peer.services.socialBotManagerService.chat.github.GitHubPRMediator;
import i5.las2peer.services.socialBotManagerService.database.SQLDatabase;
import i5.las2peer.services.socialBotManagerService.nlu.Entity;
import i5.las2peer.services.socialBotManagerService.nlu.Intent;
Expand Down Expand Up @@ -86,6 +88,20 @@ public Messenger(String id, String chatService, String token, SQLDatabase databa
case MOODLE_FORUM:
this.chatMediator = new MoodleForumMediator(token);
break;
case GITHUB_ISSUES:
try {
this.chatMediator = new GitHubIssueMediator(token);
} catch (GitHubAppHelper.GitHubAppHelperException e) {
throw new AuthTokenException(e.getMessage());
}
break;
case GITHUB_PR:
try {
this.chatMediator = new GitHubPRMediator(token);
} catch (GitHubAppHelper.GitHubAppHelperException e) {
throw new AuthTokenException(e.getMessage());
}
break;
default:
throw new ParseBotException("Unimplemented chat service: " + chatService);
}
Expand Down

0 comments on commit 5182bd2

Please sign in to comment.