Initial Commit (without the client token...) Bandori stickers in

Discord~
This commit is contained in:
sigonasr2 2018-09-26 21:02:00 -05:00
commit f527d1b049
54 changed files with 490 additions and 0 deletions

7
BandoriBot/.classpath Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="D:/Downloads/JDA-3.8.0_423-withDependencies.jar" sourcepath="D:/Downloads/JDA-3.8.0_423-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
BandoriBot/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

17
BandoriBot/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BandoriBot</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

BIN
BandoriBot/BandoriBot.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,143 @@
package sig;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import javax.security.auth.login.LoginException;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.events.Event;
import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
public class BandoriBot extends ListenerAdapter{
final public static String BASEDIR = "./";
public static HashMap<String,List<String>> stamp_map = new HashMap<String,List<String>>();
public static void main(String[] arguments) {
populateStampMap();
String[] filedata = FileUtils.readFromFile(BASEDIR+"clientToken.txt");
try {
JDA bot = new JDABuilder(filedata[0])
.addEventListener(new BandoriBot()).build();
bot.awaitReady();
} catch (LoginException | InterruptedException e) {
e.printStackTrace();
}
}
public static void populateStampMap() {
stamp_map.put("kasumi_gogo",Arrays.asList("gogo"));
stamp_map.put("tae_letsplay",Arrays.asList("playtogether","wanttoplay","multilive","letsplay"));
stamp_map.put("rimi_choco",Arrays.asList("choco","cornet"));
stamp_map.put("saya_bread",Arrays.asList("bread"));
stamp_map.put("arisa_doki",Arrays.asList("doki"));
stamp_map.put("ran_same",Arrays.asList("sameasalways","alwayssame","alwaysthesame"));
stamp_map.put("moca_youdidit",Arrays.asList("youdidit","congratulations","buns","mocatastic"));
stamp_map.put("himari_heyheyhoh",Arrays.asList("heyo","heyhey","hihi","hiyo"));
stamp_map.put("tomoe_letsdothis",Arrays.asList("letsdothis","letsdoit"));
stamp_map.put("tsugumi_wecandoit",Arrays.asList("wegotthis","wegotit","wecan"));
stamp_map.put("kokoro_happylucky",Arrays.asList("happy!","lucky"));
stamp_map.put("kaoru_fleeting",Arrays.asList("fleeting"));
stamp_map.put("aya_fever",Arrays.asList("fever","ayay"));
stamp_map.put("hagumi_smileyay",Arrays.asList("smileyay","yay"));
stamp_map.put("kanon_fuee",Arrays.asList("fue","waa","reee"));
stamp_map.put("misaki_ready",Arrays.asList("amready","beenready","ready!"));
stamp_map.put("hina_fullcombo",Arrays.asList("fcd","fullcombo","nomiss","allperfect","notasinglemiss","thefc","anfc","fullperfect"));
stamp_map.put("chisato_planned",Arrays.asList("justasplanned","allplanned","calculated","thatcoming"));
stamp_map.put("maya_huhehe",Arrays.asList("hehe","huehe","huehue"));
stamp_map.put("eve_bushido",Arrays.asList("bushido"));
stamp_map.put("yukina_notbad",Arrays.asList("notbad","veryclose"));
stamp_map.put("sayo_goodwork",Arrays.asList("goodwork","goodjob","nicejob","welldone","greatwork","greatjob"));
stamp_map.put("lisa_nextonelastone",Arrays.asList("lastone","mylast"));
stamp_map.put("ako_onemoretime",Arrays.asList("onemore","goagain","keepgoing","dontstop"));
stamp_map.put("rinko_jam",Arrays.asList("lovethissong","jam"));
stamp_map.put("marina_yeahyeah",Arrays.asList("yeahyeah","letsgo"));
stamp_map.put("kokoro_moremore",Arrays.asList("moremore","iwantmore"));
stamp_map.put("arisa_huh",Arrays.asList("huh?","hh?","yy?","aat?","aa?","tt?","nani","nand"));
stamp_map.put("yukina_followmylead",Arrays.asList("followmylead","takethelead","guideyou","fullydevoted"));
stamp_map.put("kaoru_suchalovelyevening",Arrays.asList("goodevening","lovelyevening","beautifulnight","grandnight","wonderfulevening"));
stamp_map.put("rimi_congrats",Arrays.asList("grats"));
stamp_map.put("ran_somethingbigiscoming",Arrays.asList("somethingbig","iscoming"));
stamp_map.put("tsugumi_comeon",Arrays.asList("comeon","dontbeafraid","dontbeshy","tsugurific"));
stamp_map.put("tae_fufusocute",Arrays.asList("socute","kawaii","fufu","adorable","cute"));
stamp_map.put("eve_marchintobattle",Arrays.asList("marchintobattle","chargeintobattle"));
stamp_map.put("saya_illtry",Arrays.asList("illtry","itachance","itatry","atleastonce"));
stamp_map.put("lisa_imsohappy",Arrays.asList("ecstatic","sohappy","toohappy"));
stamp_map.put("sayo_ohwell",Arrays.asList("ohwell","ahwell","youtried"));
stamp_map.put("ako_areyouokay",Arrays.asList("youok","beok","daijo"));
stamp_map.put("chisato_thisissomuchfun",Arrays.asList("muchfun","veryfun","reallyfun","extremelyfun","offun"));
stamp_map.put("rinko_theresnoway",Arrays.asList("noway"));
stamp_map.put("tae_thisisgreat",Arrays.asList("thisisgreat","thisisawesome","thisiswonderful"));
stamp_map.put("moca_thisisgettinginteresting",Arrays.asList("gettinginteresting","thingsaregetting","thisisgetting"));
stamp_map.put("kaoru_takemyhand",Arrays.asList("takemyhand","allowmeto","demonstrate","romeo"));
stamp_map.put("kokoro_letsmaketheworldsmile",Arrays.asList("hhw","happyworld","hellohappy","worldsmile"));
stamp_map.put("hina_nowwereboppin",Arrays.asList("bop","nowwere"));
}
public static void checkForStamp(MessageChannel channel, String user,String message) {
boolean foundmatch = false;
message = message.toLowerCase().replaceAll("[ ]", "");
for (String key : stamp_map.keySet()) {
for (String message_search : stamp_map.get(key)) {
String filteredmessage = message;
filteredmessage = filteredmessage.replaceAll("[^A-Za-z0-9]","");
System.out.println(filteredmessage);
if (message_search.contains("?") || message_search.contains("!")) {
if (message.contains(message_search)) {
foundmatch = true;
CreateStamp(channel,key);
System.out.println("Stamp "+key+" created by user "+user+" MESSAGE:"+message+".");
break;
}
} else {
if (filteredmessage.contains(message_search)) {
foundmatch=true;
CreateStamp(channel,key);
System.out.println("Stamp "+key+" created by user "+user+" MESSAGE:"+message+".");
break;
}
}
}
if (foundmatch) {
return;
}
}
}
public static void CreateStamp(MessageChannel channel, String stamp_name) {
channel.sendFile(new File(BASEDIR+"stamps/"+stamp_name+".png")).queue();
}
@Override
public void onMessageReceived(MessageReceivedEvent ev) {
JDA bot = ev.getJDA();
String message = ev.getMessage().getContentDisplay();
MessageChannel messaging_channel = ev.getChannel();
if (ev.isFromType(ChannelType.TEXT)) {
Channel channel = ev.getTextChannel();
Member user = ev.getMember();
System.out.println("Channel "+channel+": "+user+" - "+message);
if (user.getUser().getId().equalsIgnoreCase("494666451765035009")) {
return;
}
if (channel.getId().equalsIgnoreCase("485297375665979414")) {
System.out.println("Detected in Bandori Channel....");
checkForStamp(messaging_channel,user.getNickname(),message);
}
}
}
}

View File

@ -0,0 +1,306 @@
package sig;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.net.URL;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import sig.sigIRC;
import sig.modules.ChatLog.ChatLogMessage;
public class FileUtils {
public static String[] readFromFile(String filename) {
File file = new File(filename);
//System.out.println(file.getAbsolutePath());
List<String> contents= new ArrayList<String>();
if (file.exists()) {
try(
FileReader fw = new FileReader(filename);
BufferedReader bw = new BufferedReader(fw);)
{
String readline = bw.readLine();
do {
if (readline!=null) {
//System.out.println(readline);
contents.add(readline);
readline = bw.readLine();
}} while (readline!=null);
fw.close();
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return contents.toArray(new String[contents.size()]);
}
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
private static String readFilter(Reader rd, HashMap<Long,String> channel_ids) throws IOException {
StringBuilder sb = new StringBuilder();
boolean allowed=false;
boolean quotation_mark=false;
boolean endquotation_mark=false;
boolean foundChannel=false;
boolean nextBrace=false;
boolean outputStuff=false;
String numb = "";
int braceCount=0;
int channelCount=0;
int vals=0;
int cp;
while ((cp = rd.read()) != -1) {
if (braceCount==0) {
allowed=true;
} else
if (braceCount==1 && !quotation_mark){
quotation_mark=true;
numb="";
allowed=false;
} else
if (!endquotation_mark) {
if ((char)cp >= '0' &&
(char)cp <= '9') {
allowed=false;
numb+=(char)cp;
} else {
allowed=false;
endquotation_mark=true;
try {
if (channel_ids.containsKey(Long.parseLong(numb))) {
if (channelCount>=1) {
sb.append(",");
}
sb.append("\""+numb+"\"");
foundChannel=true;
System.out.println("Found channel "+numb);
outputStuff=true;
}
} catch (NumberFormatException e) {
}
}
} else
if (!nextBrace && foundChannel) {
allowed=true;
if ((char)cp == '{') {
nextBrace=true;
}
} else
if (foundChannel) {
allowed=true;
if (braceCount==1) {
allowed=false;
channelCount++;
quotation_mark=false;
endquotation_mark=false;
foundChannel=false;
nextBrace=false;
}
} else {
allowed=false;
if (braceCount==1) {
allowed=false;
quotation_mark=false;
endquotation_mark=false;
foundChannel=false;
nextBrace=false;
}
}
/*if (outputStuff && vals++<1000) {
System.out.print((char)cp);
}*/
if ((char)cp == '{') {
braceCount++;
//System.out.println("Brace count is "+braceCount+".");
} else
if ((char)cp == '}') {
braceCount--;
//System.out.println("Brace count is "+braceCount+".");
}
if (allowed) {
sb.append((char) cp);
}
}
sb.append("}");
//System.out.println("=============");
//System.out.println(sb.toString());
return sb.toString();
}
public static JSONObject readJsonFromUrlWithFilter(String url, HashMap<Long,String> filter) throws IOException, JSONException {
return readJsonFromUrlWithFilter(url,filter,null,false);
}
public static JSONObject readJsonFromFileWithFilter(String file, HashMap<Long,String> filter) throws IOException, JSONException {
InputStream is = new FileInputStream(new File(file));
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readFilter(rd,filter);
JSONObject json = new JSONObject(jsonText);
jsonText=null;
return json;
} finally {
is.close();
}
}
public static JSONObject readJsonFromUrlWithFilter(String url, HashMap<Long,String> filter, String file, boolean writeToFile) throws IOException, JSONException {
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readFilter(rd,filter);
if (writeToFile) {
writetoFile(new String[]{jsonText},file);
}
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
is.close();
}
}
public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
return readJsonFromUrl(url,null,false);
}
public static JSONArray readJsonArrayFromUrl(String url) throws IOException, JSONException {
return readJsonArrayFromUrl(url,null,false);
}
public static JSONObject readJsonFromFile(String file) throws IOException, JSONException {
InputStream is = new FileInputStream(new File(file));
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
jsonText=null;
return json;
} finally {
is.close();
}
}
public static JSONObject readJsonFromUrl(String url, String file, boolean writeToFile) throws IOException, JSONException {
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
if (writeToFile) {
writetoFile(new String[]{jsonText},file);
}
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
is.close();
}
}
public static JSONArray readJsonArrayFromUrl(String url, String file, boolean writeToFile) throws IOException, JSONException {
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
if (writeToFile) {
writetoFile(new String[]{jsonText},file);
}
JSONArray json = new JSONArray(jsonText);
return json;
} finally {
is.close();
}
}
public static void logToFile(String message, String filename) {
logToFile(message,filename,false);
}
public static void logToFile(String message, String filename, boolean outputToChatLog) {
File file = new File(filename);
try {
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file, true);
PrintWriter pw = new PrintWriter(fw);
pw.println(message);
pw.flush();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
if (outputToChatLog && sigIRC.chatlogmodule_enabled) {
ChatLogMessage.importMessages(message);
}
}
public static void writetoFile(String[] data, String filename) {
File file = new File(filename);
try {
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file,false);
PrintWriter pw = new PrintWriter(fw);
for (String s : data) {
pw.println(s);
}
pw.flush();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void copyFile(File source, File dest) throws IOException {
FileChannel sourceChannel = null;
FileChannel destChannel = null;
try {
sourceChannel = new FileInputStream(source).getChannel();
destChannel = new FileOutputStream(dest).getChannel();
destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
}finally{
sourceChannel.close();
destChannel.close();
}
}
public static void deleteFile(String filename) {
File file = new File(filename);
if (file.exists()) {
file.delete();
}
}
}

View File

@ -0,0 +1,5 @@
package sig;
public class MessageListener {
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB