Skip to content

Commit

Permalink
Add auto publish feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Theaninova committed Aug 14, 2020
1 parent d15fb92 commit 2741206
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 126 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
servers.json
admin.json
test.json
*.hprof
/build
/.gradle
7 changes: 7 additions & 0 deletions .idea/dictionaries/wulkanat.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 67 additions & 36 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,39 @@ A bot that automatically polls the newest blogpost from [Hytale News Tab](https:
## Setup
Okay, this isn't really meant for you to setup, if you want it though it first is easier to just dm me on Twitter [@tale_talk](https://twitter.com/tale_talk) so I can add you to the server list.
If you *really* want to set it up yourself, fine.
1. first go to the release tab, download the jar, and put it in a folder
2. Add two files in the root of the repo, an `admin.json` and a `servers.json`.
* first go to the release tab, download the jar, and put it in a folder
* Add two files in the root of the repo, an `admin.json` and a `servers.json`.
Add your Discord ID (not name), Bot token, and update frequency to the `admin.json`:
```json
{"adminId": 12345678910,"token": "AOGH@(AKnjsfjiJijaig3ijgG92jaij","updateMs":30000}
{
"adminId": 12345678910,
"token": "AOGH@(AKnjsfjiJijaig3ijgG92jaij",
"updateMs":30000
}
```
3. add an empty array to your `servers.json`
* add your servers to `servers.json`
```json
[]
[
{
"id": 15050067772322222,
"mentionedRole": "everyone",
"autoPublish":true
},
{
"id": 74050067772325222,
"mentionedRole": null,
"autoPublish":false
},
{
"id": 74050067772325222,
"mentionedRole": "74036067771625222",
"autoPublish":false
}
]
```
Not sure, but it might be that multiline JSON doesn't work.
* add a `test.json` with the same schema as the `server.json`. When
you enable test mode, the servers from there will be used instead allowing
you to test if it works.

## Compiling yourself
I developed it under Windows, and had some trouble compiling it on Linux. You mileage may vary.
Expand All @@ -22,14 +44,22 @@ I developed it under Windows, and had some trouble compiling it on Linux. You mi

Start the server with `java -jar [server-file-name]` If you put in everything correctly, the bot should message you on Discord.
### Adding Servers
Please edit the JSON file.
You can force an update by calling
```
%!addChannel [channelID] [roleID/everyone]
%!refreshList
```
Second argument is optional.
### Cause a fake update (test if it works)
### Testing
Switching between test and production files
```
%!testMode
%!fakeUpdate
```
```
%!productionMode
```
**WARNING**: Initiating a fake update is not being cancelled by switching
to production.
### Stop the server from within Discord
```
%!stop
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/Inaccessibles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import net.dv8tion.jda.internal.requests.Method;
import net.dv8tion.jda.internal.requests.Route;

import java.lang.reflect.Constructor;

public class Inaccessibles {
/**
* This is private by default
*
* @param method look
* @param route somewhere
* @return else
*/
public static Route getRoute(Method method, String route) {
try {
Constructor<?> constructor = Route.class.getDeclaredConstructor(Method.class, String.class);
constructor.setAccessible(true);
return (Route) constructor.newInstance(method, route);
} catch (Exception e) {
return null;
}
}

public static String toUnsignedString(long num) {
return Long.toUnsignedString(num);
}
}
Loading

0 comments on commit 2741206

Please sign in to comment.