-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
!trick -info will now use Gists when too large for discord...
- Loading branch information
1 parent
f062e4f
commit 681026b
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/org/mangorage/mangobot/modules/github/GistHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.mangorage.mangobot.modules.github; | ||
|
||
import org.eclipse.egit.github.core.Gist; | ||
import org.eclipse.egit.github.core.GistFile; | ||
import org.eclipse.egit.github.core.client.GitHubClient; | ||
import org.eclipse.egit.github.core.service.GistService; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public final class GistHandler { | ||
public static Gist createGist(String content, String fileName) { | ||
GitHubClient CLIENT = PasteRequestModule.GITHUB_CLIENT.get(); | ||
GistService service = new GistService(CLIENT); | ||
|
||
Gist gist = new Gist(); | ||
gist.setPublic(false); | ||
gist.setDescription("Automatically made from MangoBot."); | ||
|
||
|
||
Map<String, GistFile> fileMap = new HashMap<>(); | ||
GistFile file = new GistFile(); | ||
file.setContent(content); | ||
file.setFilename(fileName); | ||
fileMap.put(fileName, file); | ||
|
||
gist.setFiles(fileMap); | ||
|
||
try { | ||
return service.createGist(gist); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters