Skip to content

Commit

Permalink
1. Add WebSocket
Browse files Browse the repository at this point in the history
2. Remove WebHook
  • Loading branch information
megoRU committed Jul 3, 2023
1 parent f3c7b76 commit 3a0c465
Show file tree
Hide file tree
Showing 26 changed files with 351 additions and 453 deletions.
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ https://jitpack.io/#megoRU/boticordjava
<dependency>
<groupId>com.github.megoRU</groupId>
<artifactId>boticordjava</artifactId>
<version>v5.1</version>
<version>v5.3</version>
</dependency>

```
Expand Down Expand Up @@ -71,29 +71,20 @@ public class Main {
}
```

### WebHooks

Note: BotiCord supports only `HTTPS` you need proxy `ip:port` to `Apache`/`nginx` with **HTTPS**
### WebSocket

```java
public class Main {
static class Comment extends ListenerAdapter {
@Override
public void onCommentEvent(@NotNull CommentAction event) {
System.out.println(event.getType()); //delete_bot_comment
}
}

static class ServerBumpEvent extends ListenerAdapter {
@Override
public void onServerBumpEvent(@NotNull ServerBump event) {
System.out.println(event.getType()); //new_server_bump
public void onCommentEvent(@NotNull NotificationData event) {
System.out.println("event: " + event.getType());
}
}

public static void main(String[] args) {
WebSocket webSocket = new WebSocket("3fbf63cefsfs2321a", null, 8080);
webSocket.addListener(new Comment(), new ServerBumpEvent());
BoticordWebSocket boticordWebSocket = new BoticordWebSocket("token");
boticordWebSocket.addListener(new Comment());
}
}
```
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.boticordjava.api</groupId>
<artifactId>boticordjava</artifactId>
<version>5.2.1</version>
<version>5.3</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand All @@ -15,6 +15,12 @@
</properties>

<dependencies>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -36,7 +42,6 @@
<version>0.11.1</version>
</dependency>


<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand All @@ -55,7 +60,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
<version>20230618</version>
</dependency>

<dependency>
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/boticordjava/api/entity/Errors.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.boticordjava.api.entity;

public class Errors {
import org.boticordjava.api.entity.webhooks.WebhookListener;

public class Errors implements WebhookListener {

private int code;
private String message;
Expand All @@ -13,6 +15,11 @@ public String getMessage() {
return message;
}

@Override
public String getType() {
return "error";
}

@Override
public String toString() {
return "Errors code: " + code + "\nErrors message: " + message;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.boticordjava.api.entity.webhooks.notification;

import org.boticordjava.api.entity.webhooks.WebhookListener;

public class Notification implements WebhookListener {

private String event;
private NotificationData data;

public String getEvent() {
return event;
}

public NotificationData getData() {
return data;
}

@Override
public String getType() {
return data.getType();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.boticordjava.api.entity.webhooks.notification;

import org.boticordjava.api.entity.webhooks.WebhookListener;

public class NotificationData implements WebhookListener {

private String type;
private Payload payload;
private String affected;
private String id;
private String user;
private long happened;

public Payload getPayload() {
return payload;
}

public String getAffected() {
return affected;
}

public String getId() {
return id;
}

public String getUser() {
return user;
}

public long getHappened() {
return happened;
}

@Override
public String getType() {
return type;
}
}
Loading

0 comments on commit 3a0c465

Please sign in to comment.