autism
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
|
||||
ps ax | grep EventNotfierDiscordBot-1.0
|
||||
kill $pid (number)
|
||||
|
||||
nohup screen -d -m -S nonRoot java -Xmx5048M -jar /home/Artificial_Autism/ArtificialAutism-1.0.jar
|
||||
nohup screen -d -m -S nonRoot java -Xmx4048M -jar /home/Artificial_Autism/ArtificialAutism-1.0.jar
|
||||
|
||||
nohup screen -d -m -S gameservers java -Xmx2450M -jar /home/gameservers/ArtificialAutism/ArtificialAutism-1.0.jar
|
||||
screen -ls (number1)
|
||||
screen -X -S (number1) quit
|
||||
*/
|
||||
//https://discordapp.com/developers/applications/
|
||||
//https://github.com/Javacord/Javacord
|
||||
package PresentationLayer;
|
||||
|
||||
import FunctionLayer.CustomError;
|
||||
import FunctionLayer.MYSQLDatahandler;
|
||||
import FunctionLayer.MessageResponseHandler;
|
||||
import FunctionLayer.StanfordParser.SentimentAnalyzerTest;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import org.javacord.api.entity.user.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DiscordHandler {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SentimentAnalyzerTest.shiftReduceParserInitiate();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
MYSQLDatahandler.instance.initiateMYSQL();
|
||||
System.out.println("finished initiating MYSQL");
|
||||
} catch (SQLException | IOException ex) {
|
||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}).start();
|
||||
String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
||||
api.addMessageCreateListener(event -> {
|
||||
if (!event.getMessage().getAuthor().isYourself()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String strtest = event.getServerTextChannel().get().getCategory().toString();
|
||||
strtest = strtest.substring(9, strtest.length() - 1);
|
||||
boolean channelpermissionsDenied = false;
|
||||
switch (strtest) {
|
||||
case "Server Area": {
|
||||
if (!event.getServerTextChannel().get().toString().contains("chat-live")) {
|
||||
channelpermissionsDenied = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Public Area": {
|
||||
break;
|
||||
}
|
||||
case "Information Area": {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
channelpermissionsDenied = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!channelpermissionsDenied) {
|
||||
List<User> userlist = event.getMessage().getMentionedUsers();
|
||||
String strresult = event.getMessage().toString();
|
||||
if (userlist != null) {
|
||||
for (int i = 0; i < userlist.size(); i++) {
|
||||
strresult = strresult.replace(userlist.get(i).getIdAsString(), "");
|
||||
}
|
||||
}
|
||||
MessageResponseHandler.getMessage(strresult);
|
||||
try {
|
||||
MYSQLDatahandler.instance.checkIfUpdateStrings();
|
||||
MYSQLDatahandler.instance.checkIfUpdateMatrixes();
|
||||
} catch (CustomError ex) {
|
||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
//contains to specify one channel where bot may always type
|
||||
if (event.getMessage().getMentionedUsers().contains(api.getYourself())
|
||||
|| event.getServerTextChannel().get().toString().contains("minor-test")) {
|
||||
String ResponseStr;
|
||||
try {
|
||||
ResponseStr = MessageResponseHandler.selectReponseMessage(event.getMessage().toString());
|
||||
if (!ResponseStr.isEmpty()) {
|
||||
System.out.print("\nResponseStr3: " + ResponseStr);
|
||||
event.getChannel().sendMessage(ResponseStr);
|
||||
}
|
||||
} catch (CustomError ex) {
|
||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user