Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slack api #124

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>com.github.seratch</groupId>
<artifactId>jslack-lightning</artifactId>
<version>3.4.2</version>
<groupId>com.slack.api</groupId>
<artifactId>slack-api-client</artifactId>
<version>1.39.3</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/com/botdarr/clients/matrix/MatrixBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.botdarr.scheduling.Scheduler;
import org.apache.logging.log4j.util.Strings;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

public class MatrixBootstrap extends ChatClientBootstrap {
Expand All @@ -28,13 +30,28 @@ public void init() throws Exception {
chatClient.listen();
}

private boolean isValidURL(String urlString) {
try {
new URL(urlString);
return true;
} catch (MalformedURLException e) {
return false;
}
}

@Override
public boolean isConfigured(Properties properties) {
return
final boolean isConfigured =
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_USERNAME)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_PASSWORD)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_ROOM)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER));
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_PASSWORD)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_ROOM)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER));

if (isConfigured && !isValidURL(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER))) {
throw new RuntimeException("Matrix home server must be a url");
}

return isConfigured;
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/botdarr/clients/slack/SlackBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.botdarr.clients.ChatClientResponseBuilder;
import com.botdarr.commands.CommandContext;
import com.botdarr.scheduling.Scheduler;
import com.github.seratch.jslack.Slack;
import com.github.seratch.jslack.api.model.Message;
import com.github.seratch.jslack.api.model.User;
import com.github.seratch.jslack.api.model.block.LayoutBlock;
import com.github.seratch.jslack.api.model.block.SectionBlock;
import com.github.seratch.jslack.api.model.block.composition.MarkdownTextObject;
import com.github.seratch.jslack.api.rtm.RTMMessageHandler;
import com.slack.api.Slack;
import com.slack.api.model.Message;
import com.slack.api.model.User;
import com.slack.api.model.block.LayoutBlock;
import com.slack.api.model.block.SectionBlock;
import com.slack.api.model.block.composition.MarkdownTextObject;
import com.slack.api.rtm.RTMMessageHandler;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void handle(String message) {
}
if (conversationMessages != null) {
conversationMessageLoop:
for (com.github.seratch.jslack.api.model.Message conversationMessage : conversationMessages) {
for (com.slack.api.model.Message conversationMessage : conversationMessages) {
for (LayoutBlock layoutBlock : conversationMessage.getBlocks()) {
if (layoutBlock.getType().equals("section")) {
SectionBlock sectionBlock = (SectionBlock) layoutBlock;
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/com/botdarr/clients/slack/SlackChatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import com.botdarr.Config;
import com.botdarr.clients.ChatClient;
import com.github.seratch.jslack.Slack;
import com.github.seratch.jslack.api.methods.SlackApiException;
import com.github.seratch.jslack.api.methods.request.chat.ChatPostMessageRequest;
import com.github.seratch.jslack.api.methods.request.conversations.ConversationsHistoryRequest;
import com.github.seratch.jslack.api.methods.request.conversations.ConversationsListRequest;
import com.github.seratch.jslack.api.methods.request.groups.GroupsHistoryRequest;
import com.github.seratch.jslack.api.methods.request.users.UsersInfoRequest;
import com.github.seratch.jslack.api.methods.response.conversations.ConversationsListResponse;
import com.github.seratch.jslack.api.model.Conversation;
import com.github.seratch.jslack.api.model.ConversationType;
import com.github.seratch.jslack.api.model.Message;
import com.github.seratch.jslack.api.model.User;
import com.github.seratch.jslack.api.model.block.DividerBlock;
import com.github.seratch.jslack.api.model.block.LayoutBlock;
import com.github.seratch.jslack.api.rtm.RTMClient;
import com.github.seratch.jslack.api.rtm.RTMMessageHandler;
import com.slack.api.Slack;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.chat.ChatPostMessageRequest;
import com.slack.api.methods.request.conversations.ConversationsHistoryRequest;
import com.slack.api.methods.request.conversations.ConversationsListRequest;
import com.slack.api.methods.request.groups.GroupsHistoryRequest;
import com.slack.api.methods.request.users.UsersInfoRequest;
import com.slack.api.methods.response.conversations.ConversationsListResponse;
import com.slack.api.model.Conversation;
import com.slack.api.model.ConversationType;
import com.slack.api.model.Message;
import com.slack.api.model.User;
import com.slack.api.model.block.DividerBlock;
import com.slack.api.model.block.LayoutBlock;
import com.slack.api.rtm.RTMClient;
import com.slack.api.rtm.RTMMessageHandler;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import org.apache.logging.log4j.LogManager;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/botdarr/clients/slack/SlackResponse.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.botdarr.clients.slack;

import com.botdarr.clients.ChatClientResponse;
import com.github.seratch.jslack.api.model.block.LayoutBlock;
import com.slack.api.model.block.LayoutBlock;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import com.botdarr.commands.*;
import com.botdarr.commands.responses.*;
import com.botdarr.utilities.ListUtils;
import com.github.seratch.jslack.api.model.block.*;
import com.github.seratch.jslack.api.model.block.composition.MarkdownTextObject;
import com.github.seratch.jslack.api.model.block.composition.PlainTextObject;
import com.github.seratch.jslack.api.model.block.element.ButtonElement;
import com.slack.api.model.block.*;
import com.slack.api.model.block.composition.MarkdownTextObject;
import com.slack.api.model.block.composition.PlainTextObject;
import com.slack.api.model.block.element.ButtonElement;
import org.apache.logging.log4j.util.Strings;

import java.io.IOException;
Expand Down
Loading