Skip to content

Commit

Permalink
Merge pull request #9 from boticord/webhooks
Browse files Browse the repository at this point in the history
Webhooks
  • Loading branch information
megoRU authored Dec 4, 2022
2 parents 7ffbbf9 + 9e2c195 commit 6cdbd76
Show file tree
Hide file tree
Showing 19 changed files with 570 additions and 58 deletions.
68 changes: 48 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center ">

<p></p>
<a href="https://boticord.top"><img src="https://megoru.ru/boticordapi2.png" alt="boticord.js"/></a>
<p>
Expand All @@ -9,25 +9,26 @@
</div>

# BotiCordJava
An API wrapper for https://boticord.top/ written in Java by @megoRU

An API wrapper for https://boticord.top/ written in Java by @megoRU

### Maven

https://jitpack.io/#megoRU/boticordjava

```xml

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependency>
<groupId>com.github.megoRU</groupId>
<artifactId>boticordjava</artifactId>
<version>v3.7</version>
<groupId>com.github.megoRU</groupId>
<artifactId>boticordjava</artifactId>
<version>v3.7</version>
</dependency>

```
Expand All @@ -37,19 +38,19 @@ https://jitpack.io/#megoRU/boticordjava
### Get All Comments by bot ID

```java
public static void main(String[] args) {
BotiCordAPI api = new BotiCordAPI.Builder()
public static void main(String[]args){
BotiCordAPI api=new BotiCordAPI.Builder()
.tokenEnum(TokenEnum.BOT)
.token("319bbc0e-0743-4d9c-872b-e547d5e8fd0d")
.build();

try {
Comments[] comments = api.getBotComments("808277484524011531");
try{
Comments[]comments=api.getBotComments("808277484524011531");

for (int i = 0; i < comments.length; i++) {
for(int i=0;i<comments.length;i++){
System.out.println(comments[i].getText());
}
} catch (UnsuccessfulHttpException e) {
}catch(UnsuccessfulHttpException e){
System.out.println(e.getMessage());
}
}
Expand All @@ -58,17 +59,44 @@ public static void main(String[] args) {
### Update Stats

```java
public static void main(String[] args) {
BotiCordAPI api = new BotiCordAPI.Builder()
public static void main(String[]args){
BotiCordAPI api=new BotiCordAPI.Builder()
.tokenEnum(TokenEnum.BOT)
.token("319bbc0e-0743-4d9c-872b-e547d5e8fd0d")
.build();

try {
Result result = api.setStats(500, 1, 2000);
try{
Result result=api.setStats(500,1,2000);
System.out.println(result);
} catch (UnsuccessfulHttpException e) {
}catch(UnsuccessfulHttpException e){
System.out.println(e.getMessage());
}
}
```

### WebHooks

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

```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 static void main(String[] args) {
WebSocket webSocket = new WebSocket("3fbf63cefsfs2321a", null, 8080);
webSocket.addListener(new Comment(), new ServerBumpEvent());
}
}
```
Expand Down
83 changes: 45 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.boticordjava.api</groupId>
<artifactId>boticordjava</artifactId>
<version>3.7</version>
<version>4.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand All @@ -15,6 +14,50 @@
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
</dependency>


<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
</dependency>

<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -53,40 +96,4 @@
</plugins>
</build>

<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
</dependency>

<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.boticordjava.api.entity.webhooks;

public interface WebhookListener {

String getType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.boticordjava.api.entity.webhooks.bump.bot;

import java.sql.Timestamp;

public class Bonus {

private String status;
private Long expiresAt;

public String getStatus() {
return status;
}

public Timestamp getExpiresAt() {
return new Timestamp(expiresAt);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.boticordjava.api.entity.webhooks.bump.bot;

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

public class BotBump implements WebhookListener {

private String type;
private Data data;
private Bonus bonus;

public String getType() {
return type;
}

public Data getData() {
return data;
}

public Bonus getBonus() {
return bonus;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.boticordjava.api.entity.webhooks.bump.bot;

import java.sql.Timestamp;

public class Data {

private String user;
private Long at;

public String getUser() {
return user;
}

public Timestamp getAt() {
return new Timestamp(at);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.boticordjava.api.entity.webhooks.bump.server;

import org.boticordjava.api.entity.webhooks.WebhookListener;
import org.boticordjava.api.entity.webhooks.bump.bot.Data;

public class ServerBump implements WebhookListener {

private String type;
private Data data;

public String getType() {
return type;
}

public Data getData() {
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.boticordjava.api.entity.webhooks.comment;

import com.google.gson.annotations.SerializedName;
import org.boticordjava.api.entity.webhooks.WebhookListener;

public class BotComment implements WebhookListener {

private String type;
@SerializedName("data")
private CommentData commentData;

public String getType() {
return type;
}

public CommentData getData() {
return commentData;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.boticordjava.api.entity.webhooks.comment;

import com.google.gson.annotations.SerializedName;

public class Comment {

private Vote vote;

@SerializedName("old")
private String oldComment;

@SerializedName("new")
private String newComment;

public Vote getVote() {
return vote;
}

public String getOldComment() {
return oldComment;
}

public String getNewComment() {
return newComment;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.boticordjava.api.entity.webhooks.comment;

import com.google.gson.annotations.SerializedName;
import org.boticordjava.api.entity.webhooks.WebhookListener;
import org.boticordjava.api.entity.webhooks.bump.bot.Bonus;

public class CommentAction implements WebhookListener {

private String type;
@SerializedName("data")
private CommentData commentData;
private Bonus bonus;

public String getType() {
return type;
}

public CommentData getData() {
return commentData;
}

public Bonus getBonus() {
return bonus;
}
}
Loading

0 comments on commit 6cdbd76

Please sign in to comment.