it is time to welcome............... Spring!!!!!
This commit is contained in:
parent
21e94b9a42
commit
983678f656
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,8 +1,11 @@
|
||||
.idea/
|
||||
.gradle
|
||||
config/
|
||||
lib/
|
||||
logs/
|
||||
out/
|
||||
|
||||
/build/
|
||||
*.iml
|
||||
META-INF/
|
||||
*.uml
|
||||
|
@ -2,7 +2,7 @@
|
||||
<Configuration status="error">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%highlight{[%d{HH:mm:ss.SSS}][%-5level]%logger{2}: %msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}" />
|
||||
<PatternLayout pattern="[%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}" />
|
||||
<!--{FATAL=red blink, ERROR=red, WARN=orange, INFO=yellow, DEBUG=green bold, TRACE=blue}-->
|
||||
</Console>
|
||||
<!--<RollingFile name="RollingFile" fileName="/logs/curent.log"
|
||||
|
39
build.gradle
Normal file
39
build.gradle
Normal file
@ -0,0 +1,39 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
jar {
|
||||
baseName = 'DiscordBot'
|
||||
version = '0.1.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web"){
|
||||
exclude group:"org.springframework.boot", module: "spring-boot-starter-logging"
|
||||
}
|
||||
compile("org.springframework.boot:spring-boot-starter-log4j2")
|
||||
compile("com.sedmelluq:lavaplayer:1.2.45")
|
||||
compile 'net.dv8tion:JDA:3.3.1_303'
|
||||
compile group: 'org.json', name: 'json', version: '20160810'
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
testCompile('com.jayway.jsonpath:json-path')
|
||||
}
|
||||
|
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Mon Dec 11 22:24:31 CET 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip
|
172
gradlew
vendored
Normal file
172
gradlew
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
67
pom.xml
67
pom.xml
@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>central</groupId>
|
||||
<artifactId>Discord_Stroumpf_Beta</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>bintray</name>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sedmelluq</groupId>
|
||||
<artifactId>lavaplayer</artifactId>
|
||||
<version>1.2.42</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<!--<version>3.3.0_260</version>-->
|
||||
<version>3.3.1_303</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -22,7 +22,6 @@ import net.dv8tion.jda.core.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.core.managers.GuildManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import sun.security.tools.keytool.Main;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
116
src/main/java/net/Broken/Init.java
Normal file
116
src/main/java/net/Broken/Init.java
Normal file
@ -0,0 +1,116 @@
|
||||
package net.Broken;
|
||||
|
||||
import net.Broken.Commandes.*;
|
||||
import net.Broken.Commandes.Over18.*;
|
||||
import net.Broken.Outils.DayListener;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDABuilder;
|
||||
import net.dv8tion.jda.core.OnlineStatus;
|
||||
import net.dv8tion.jda.core.entities.Game;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
||||
import net.dv8tion.jda.core.managers.GuildManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.util.List;
|
||||
|
||||
public class Init {
|
||||
static private Logger logger = LogManager.getLogger();
|
||||
|
||||
static JDA initBot(String token, boolean dev){
|
||||
boolean okInit;
|
||||
JDA jda = null;
|
||||
logger.info("-------------------INITIALISATION-------------------");
|
||||
|
||||
//Bot démarrer sans token
|
||||
if (token == null) {
|
||||
logger.fatal("Veuilliez indiquer le token du bot en argument...");
|
||||
okInit=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Token présent
|
||||
try
|
||||
{
|
||||
|
||||
logger.info("Connection au serveur...");
|
||||
//connection au bot
|
||||
jda = new JDABuilder(AccountType.BOT).addEventListener(new BotListener()).setToken(token).setBulkDeleteSplittingEnabled(false).buildBlocking();
|
||||
jda.setAutoReconnect(true);
|
||||
jda.addEventListener();
|
||||
|
||||
/*************************************
|
||||
* Definition des commande *
|
||||
*************************************/
|
||||
jda.getPresence().setGame(Game.of("Statut: Loading..."));
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
MainBot.commandes.put("ping", new PingCommande());
|
||||
MainBot.commandes.put("help", new Help());
|
||||
MainBot.commandes.put("move", new Move());
|
||||
MainBot.commandes.put("spam", new Spam());
|
||||
MainBot.commandes.put("spaminfo", new SpamInfo());
|
||||
MainBot.commandes.put("flush", new Flush());
|
||||
MainBot.commandes.put("music", new Music());
|
||||
|
||||
if (!dev) {
|
||||
MainBot.commandes.put("ass", new Ass());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
MainBot.commandes.put("boobs", new Boobs());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
MainBot.commandes.put("pipe", new Pipe());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
MainBot.commandes.put("sm", new SM());
|
||||
MainBot.commandes.put("madame", new Madame());
|
||||
MainBot.commandes.put("cat", new Cat());
|
||||
}
|
||||
|
||||
|
||||
//On recupere le l'id serveur
|
||||
Guild serveur = jda.getGuilds().get(0);
|
||||
|
||||
//on recupere les utilisateur
|
||||
List<Member> utilisateurCo = serveur.getMembers();
|
||||
|
||||
logger.info("Utilisatieur connecté: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo)
|
||||
{
|
||||
if (anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.ONLINE))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName());
|
||||
}
|
||||
|
||||
logger.info("Utilisatieur absent: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo)
|
||||
{
|
||||
if (anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.DO_NOT_DISTURB))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName());
|
||||
}
|
||||
|
||||
logger.info("Utilisatieur hors ligne: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo)
|
||||
{
|
||||
if (anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.OFFLINE))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName());
|
||||
}
|
||||
|
||||
MainBot.ModoTimer modotimer = new MainBot.ModoTimer();
|
||||
modotimer.start();
|
||||
DayListener dayListener = new DayListener();
|
||||
dayListener.start();
|
||||
logger.info("-----------------FIN INITIALISATION-----------------");
|
||||
|
||||
jda.getPresence().setGame(Game.of("Statut: Ok!"));
|
||||
|
||||
}
|
||||
catch (LoginException | InterruptedException | RateLimitedException e)
|
||||
{
|
||||
logger.catching(e);
|
||||
}
|
||||
}
|
||||
|
||||
return jda;
|
||||
}
|
||||
}
|
@ -1,37 +1,32 @@
|
||||
package net.Broken;
|
||||
|
||||
import net.Broken.Commandes.*;
|
||||
import net.Broken.Commandes.Over18.*;
|
||||
import net.Broken.Outils.CommandParser;
|
||||
import net.Broken.Outils.DayListener;
|
||||
import net.Broken.Outils.EmbedMessageUtils;
|
||||
import net.Broken.Outils.UserSpamUtils;
|
||||
import net.Broken.audio.AudioM;
|
||||
import net.dv8tion.jda.core.*;
|
||||
import net.dv8tion.jda.core.entities.*;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
||||
import net.dv8tion.jda.core.managers.GuildManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.boot.ExitCodeGenerator;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by seb65 on 19/10/2016.
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class MainBot {
|
||||
|
||||
private static boolean dev = false;
|
||||
private static String token = null;
|
||||
private static JDA jda;
|
||||
|
||||
public static final CommandParser parser =new CommandParser();
|
||||
public static HashMap<String, Commande> commandes = new HashMap<>();
|
||||
public static boolean okInit=false;
|
||||
public static HashMap<User, ArrayList<Message>> historique =new HashMap<>();
|
||||
public static HashMap<User, Integer> message_compteur =new HashMap<>();
|
||||
public static boolean roleFlag = false;
|
||||
@ -42,12 +37,16 @@ public class MainBot {
|
||||
|
||||
private static Logger logger = LogManager.getLogger();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(MainBot.class, args);
|
||||
logger.trace("trace");
|
||||
logger.debug("debug");
|
||||
logger.info("info");
|
||||
logger.warn("warn");
|
||||
logger.error("error");
|
||||
|
||||
boolean dev = false;
|
||||
String token = null;
|
||||
int i = 0;
|
||||
for(String aArg: args){
|
||||
logger.debug(aArg);
|
||||
@ -63,107 +62,13 @@ public class MainBot {
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/****************************
|
||||
* Initialisation *
|
||||
****************************/
|
||||
logger.info("-------------------INITIALISATION-------------------");
|
||||
//Bot démarrer sans token
|
||||
if (token == null) {
|
||||
logger.fatal("Veuilliez indiquer le token du bot en argument...");
|
||||
okInit=false;
|
||||
JDA jda = Init.initBot(token, dev);
|
||||
if(jda == null) {
|
||||
System.exit(SpringApplication.exit(ctx, (ExitCodeGenerator) () -> {
|
||||
logger.fatal("Init error! Close application!");
|
||||
return 1;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Token présent
|
||||
try
|
||||
{
|
||||
|
||||
logger.info("Connection au serveur...");
|
||||
//connection au bot
|
||||
jda = new JDABuilder(AccountType.BOT).addEventListener(new BotListener()).setToken(token).setBulkDeleteSplittingEnabled(false).buildBlocking();
|
||||
jda.setAutoReconnect(true);
|
||||
jda.addEventListener();
|
||||
okInit=true;
|
||||
|
||||
}
|
||||
catch (LoginException | InterruptedException | RateLimitedException e)
|
||||
{
|
||||
logger.catching(e);
|
||||
okInit=false;
|
||||
}
|
||||
}
|
||||
|
||||
//Connection reussi
|
||||
if(okInit)
|
||||
{
|
||||
/*************************************
|
||||
* Definition des commande *
|
||||
*************************************/
|
||||
jda.getPresence().setGame(Game.of("Statut: Loading..."));
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
commandes.put("ping", new PingCommande());
|
||||
commandes.put("help",new Help());
|
||||
commandes.put("move", new Move());
|
||||
commandes.put("spam", new Spam());
|
||||
commandes.put("spaminfo",new SpamInfo());
|
||||
commandes.put("flush",new Flush());
|
||||
commandes.put("music",new Music());
|
||||
|
||||
if(!dev){
|
||||
commandes.put("ass",new Ass());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
commandes.put("boobs",new Boobs());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
commandes.put("pipe",new Pipe());
|
||||
jda.getTextChannels().forEach(textChannel -> textChannel.sendTyping().queue());
|
||||
commandes.put("sm",new SM());
|
||||
commandes.put("madame",new Madame());
|
||||
commandes.put("cat",new Cat());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//On recupere le l'id serveur
|
||||
Guild serveur = jda.getGuilds().get(0);
|
||||
|
||||
|
||||
//On recupere le serveur manageur
|
||||
GuildManager guildManager = serveur.getManager();
|
||||
|
||||
//on recupere les utilisateur
|
||||
List<Member> utilisateurCo = serveur.getMembers();
|
||||
|
||||
logger.info("Utilisatieur connecté: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo) //= for(int i=0; i<utilisateurCo.size(); i++)
|
||||
{
|
||||
if(anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.ONLINE))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName()); //anUtilisateurCo = utilisateurCo.get(i)
|
||||
}
|
||||
logger.info("Utilisatieur absent: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo) //= for(int i=0; i<utilisateurCo.size(); i++)
|
||||
{
|
||||
if(anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.DO_NOT_DISTURB))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName()); //anUtilisateurCo = utilisateurCo.get(i)
|
||||
}
|
||||
logger.info("Utilisatieur hors ligne: ");
|
||||
for (Member anUtilisateurCo : utilisateurCo) //= for(int i=0; i<utilisateurCo.size(); i++)
|
||||
{
|
||||
if(anUtilisateurCo.getOnlineStatus().equals(OnlineStatus.OFFLINE))
|
||||
logger.info("\t*" + anUtilisateurCo.getEffectiveName()); //anUtilisateurCo = utilisateurCo.get(i)
|
||||
}
|
||||
ModoTimer modotimer = new ModoTimer();
|
||||
modotimer.start();
|
||||
DayListener dayListener =new DayListener();
|
||||
dayListener.start();
|
||||
logger.info("-----------------FIN INITIALISATION-----------------");
|
||||
|
||||
jda.getPresence().setGame(Game.of("Statut: Ok!"));
|
||||
// MessageEmbed test = EmbedMessageUtils.getHelp("test",command)
|
||||
// jda.getTextChannels().get(0).sendMessage(test).queue();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************
|
||||
@ -217,15 +122,14 @@ public class MainBot {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while (true)
|
||||
while(true)
|
||||
{
|
||||
try {
|
||||
sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//System.out.println("\n5sec Ecoulées !");
|
||||
for (User unUser: message_compteur.keySet() ) //=for(int i=0; i<saveRoleUser.size(); i++)
|
||||
for (User unUser: message_compteur.keySet())
|
||||
{
|
||||
MainBot.message_compteur.put(unUser, 0);
|
||||
}
|
||||
|
25
src/main/resources/log4j2.xml
Normal file
25
src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="error">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink, ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}" />
|
||||
</Console>
|
||||
<!--<RollingFile name="RollingFile" fileName="/logs/curent.log"
|
||||
filePattern="/logs/$${date:yyyy-MM}/discordBot-%d{yyyy-MM-dd-HH}-%i.log.gz">
|
||||
<PatternLayout>
|
||||
<Pattern>[%d{yyy-MM-dd ~ HH:mm:ss.SSS}][%-5level]%logger{36}: %msg%n</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy minSize="1B"/>
|
||||
<TimeBasedTriggeringPolicy/>
|
||||
<SizeBasedTriggeringPolicy size="250 MB"/>
|
||||
</Policies>
|
||||
</RollingFile>-->
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console" level="info"/>
|
||||
<AppenderRef ref="RollingFile" level="info"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
Reference in New Issue
Block a user