diff --git a/build.gradle b/build.gradle index f2fc6ab..8c72ad5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,6 @@ plugins { id 'application' id 'java' - id "com.github.ben-manes.versions" version "0.28.0" - id "com.github.johnrengelman.shadow" version "5.2.0" } mainClassName = 'net.romvoid.crashbot.Bot' @@ -19,16 +17,26 @@ maven { url "https://jitpack.io" } + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } jcenter() + mavenCentral() } - dependencies { + compile group: 'org.igniterealtime.smack', name: 'smack-java8', version: '4.4.4' + // Optional for XMPPTCPConnection + compile group: 'org.igniterealtime.smack', name: 'smack-tcp', version: '4.4.4' + // Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …) + compile group: 'org.igniterealtime.smack', name: 'smack-im', version: '4.4.4' + // Optional for XMPP extensions support +// compile 'org.igniterealtime.smack:smack-extensions:4.4.4' + compile ('net.dv8tion:JDA:4.1.1_164'){ transitive = true exclude module: 'opus-java' } //compile group: '', name: '', version: '' - compile group: 'com.jagrosh', name: 'jda-utilities', version: '3.0.4' // https://mvnrepository.com/artifact/commons-io/commons-io @@ -56,31 +64,23 @@ compile group: 'club.minnced', name: 'discord-webhooks', version: '0.3.1' // https://search.maven.org/artifact/com.github.enerccio/gson-utilities/1.1.0/jar - compile group: 'com.github.enerccio', name: 'gson-utilities', version: '1.1.0' +// compile group: 'com.github.enerccio', name: 'gson-utilities', version: '1.1.0' // https://mvnrepository.com/artifact/org.jsoup/jsoup compile group: 'org.jsoup', name: 'jsoup', version: '1.13.1' // https://search.maven.org/artifact/org.junit.jupiter/junit-jupiter-engine - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.0-M1' - + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2' + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2' compile(group: 'org.kohsuke', name: 'github-api', version: '1.95'){ exclude module: 'okhttp' } - - compile 'com.github.ROMVoid95:ReadOnlyCfg:1.0.2' - } - -shadowJar { task -> - baseName = task.project.name -} - jar { configurations.compile.each { dep -> from(project.zipTree(dep)) { - exclude 'META-INF', 'META-INF/**' + // exclude 'META-INF', 'META-INF/**' } } manifest { diff --git a/src/main/java/net/romvoid/crashbot/Bot.java b/src/main/java/net/romvoid/crashbot/Bot.java index 00d2158..616e246 100644 --- a/src/main/java/net/romvoid/crashbot/Bot.java +++ b/src/main/java/net/romvoid/crashbot/Bot.java @@ -25,6 +25,7 @@ import static net.dv8tion.jda.api.requests.GatewayIntent.*; import java.io.File; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashSet; @@ -33,6 +34,14 @@ import javax.security.auth.login.LoginException; import net.romvoid.crashbot.commands.StatusCommand; + +import org.jivesoftware.smack.AbstractXMPPConnection; +import org.jivesoftware.smack.SmackException; +import org.jivesoftware.smack.XMPPException; +import org.jivesoftware.smack.tcp.XMPPTCPConnection; +import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; + +import org.jxmpp.stringprep.XmppStringprepException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,6 +108,7 @@ client.addCommands(new InviteCommand(), new GuildlistCommand(waiter), new GitCommand(), new StatusCommand()); initJDA(); + initJabber(); } @@ -134,6 +144,31 @@ getJDA().getPresence().setActivity(Activity.playing("MFND.ru")); } + public static void initJabber() { + try { + XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() + .setUsernameAndPassword("crashlogbot", "cf615weIDQWL") + .setXmppDomain("mfnd.ru") + .setHost("xmpp.mfnd.ru") + .setPort(5222) + .setResource("MFND CrashLogBot") + .build(); + AbstractXMPPConnection connection = new XMPPTCPConnection(config); + connection.setReplyTimeout(30000); + connection.connect().login(); + } catch (SmackException e) { + e.printStackTrace(); + } catch (XmppStringprepException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (XMPPException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private void setIntents() { intents.add(GUILD_MESSAGES); intents.add(GUILD_MEMBERS); diff --git a/src/main/java/net/romvoid/crashbot/commands/StatusCommand.java b/src/main/java/net/romvoid/crashbot/commands/StatusCommand.java index 0259f2e..58eada5 100644 --- a/src/main/java/net/romvoid/crashbot/commands/StatusCommand.java +++ b/src/main/java/net/romvoid/crashbot/commands/StatusCommand.java @@ -24,6 +24,7 @@ } @Override protected void execute(CommandEvent event) { + String google = "https://www.google.com/"; String mfnd = "https://www.mfnd.ru/"; Bot.LOG.info(event.getAuthor().getName() + " invoked command " + this.name); @@ -46,6 +47,14 @@ embed.addField("", "Site activity - FAIL", false); embed.setColor(Color.red); } +// if () { +// embed.addField("", "Jabber activity - OK", false); +// embed.setColor(Color.green); +// } else +// { +// embed.addField("", "Jabber activity - FAIL", false); +// embed.setColor(Color.red); +// } Message msg = EmbedUtil.message(embed); EmbedUtil.sendAndDeleteOnGuilds(channel, msg, -1, TimeUnit.MINUTES); }