Skip to content

Commit

Permalink
2.4.3
Browse files Browse the repository at this point in the history
+ added Delete Logging, requires a logging channel to be set up and
DeleteLogging to be true (defalt false)
  • Loading branch information
Vaerys-Dawn committed Feb 13, 2017
1 parent f278403 commit 03ea29c
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 211 deletions.
318 changes: 114 additions & 204 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.vaerys</groupId>
<artifactId>DiscordSAIL</artifactId>
<version>2.4.2</version>
<version>2.4.3</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.vaerys</groupId>
<artifactId>DiscordSAIL</artifactId>
<version>2.4.2</version>
<version>2.4.3</version>

<build>
<resources>
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/Listeners/AnnotationListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Listeners;

import Commands.Command;
import Commands.CommandObject;
import Handlers.DMHandler;
import Handlers.FileHandler;
Expand All @@ -13,11 +14,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sx.blah.discord.api.events.EventSubscriber;
import sx.blah.discord.api.internal.json.event.MessageDeleteEventResponse;
import sx.blah.discord.handle.impl.events.ReadyEvent;
import sx.blah.discord.handle.impl.events.guild.GuildCreateEvent;
import sx.blah.discord.handle.impl.events.guild.GuildLeaveEvent;
import sx.blah.discord.handle.impl.events.guild.channel.ChannelDeleteEvent;
import sx.blah.discord.handle.impl.events.guild.channel.message.MentionEvent;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageDeleteEvent;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
import sx.blah.discord.handle.impl.events.guild.channel.message.reaction.ReactionAddEvent;
import sx.blah.discord.handle.impl.events.guild.role.RoleDeleteEvent;
Expand Down Expand Up @@ -232,4 +235,39 @@ public void onReactionAddEvent(ReactionAddEvent event) {
}
}
}

@EventSubscriber
public void onMessageDeleteEvent(MessageDeleteEvent event){
if (event.getChannel().isPrivate()){
return;
}
CommandObject command = new CommandObject(event.getMessage());
String content;
IChannel logging = command.client.getChannelByID(command.guildConfig.getChannelTypeID(Command.CHANNEL_SERVER_LOG));
IUser ourUser = command.client.getOurUser();
if (command.guildConfig.getChannelTypeID(Command.CHANNEL_INFO).equals(command.channelID) && ourUser.getID().equals(command.authorID)){
return;
}
if (command.guildConfig.getChannelTypeID(Command.CHANNEL_SERVER_LOG).equals(command.channelID) && ourUser.getID().equals(command.authorID)){
return;
}
if (command.guildConfig.getChannelTypeID(Command.CHANNEL_ADMIN_LOG).equals(command.channelID) && ourUser.getID().equals(command.authorID)){
return;
}
if (logging != null && command.guildConfig.doDeleteLogging()){
if (command.message.getContent().isEmpty()){
return;
}
int charlimit = 1800;
if (command.message.getContent().length() > charlimit){
content = command.message.getContent().substring(0,1800);
}else {
content = command.message.getContent();
}
if ((content.equals("`Loading...`") || content.equals("`Working...`")) && command.authorID.equals(command.client.getOurUser().getID())){
return;
}
Utility.sendMessage("> **@" + command.authorUserName+ "'s** Message was deleted in channel: " + command.channel.mention() + " with contents:\n" + content,logging);
}
}
}
14 changes: 12 additions & 2 deletions src/main/java/POGOs/GuildConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class GuildConfig {
boolean loginMessage = true;
boolean generalLogging = false;
boolean adminLogging = false;
boolean deleteLogging = false;
boolean blackListing = false;
boolean maxMentions = true;
boolean dailyMessage = true;
Expand Down Expand Up @@ -110,6 +111,10 @@ public boolean doAdminLogging() {
return adminLogging;
}

public boolean doDeleteLogging() {
return deleteLogging;
}

public boolean doMaxMentions() {
return maxMentions;
}
Expand Down Expand Up @@ -158,6 +163,11 @@ public boolean toggleAdminLogging() {
return adminLogging = !adminLogging;
}

@ToggleAnnotation(name = "DeleteLogging")
public boolean toggleDeleteLogging() {
return deleteLogging = !deleteLogging;
}

@ToggleAnnotation(name = "BlackListing")
public boolean toggleDoBlackListing() {
return blackListing = !blackListing;
Expand Down Expand Up @@ -209,7 +219,7 @@ public boolean toggleModuleServers() {
}

public void setUpChannel(String channelType, String channelID) {
if (channelType.equals(Command.CHANNEL_SERVERS) && !moduleServers){
if (channelType.equals(Command.CHANNEL_SERVERS) && !moduleServers) {
return;
}
if (channels.size() == 0) {
Expand All @@ -228,7 +238,7 @@ public void setUpChannel(String channelType, String channelID) {
public String getChannelTypeID(String channelType) {
for (ChannelTypeObject c : channels) {
if (c.getType().equals(channelType)) {
if (channelType.equalsIgnoreCase(Command.CHANNEL_SERVERS) && !moduleServers){
if (channelType.equalsIgnoreCase(Command.CHANNEL_SERVERS) && !moduleServers) {
return null;
}
return c.getID();
Expand Down
Binary file modified target/JavaDiscordSAILv2.jar
Binary file not shown.
Binary file modified target/classes/Listeners/AnnotationListener.class
Binary file not shown.
Binary file modified target/classes/POGOs/GuildConfig.class
Binary file not shown.
2 changes: 1 addition & 1 deletion target/classes/project.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.4.2
version=2.4.3
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Mon Feb 13 17:21:06 AEDT 2017
version=2.4.2
#Mon Feb 13 18:55:32 AEDT 2017
version=2.4.3
groupId=com.github.vaerys
artifactId=DiscordSAIL
Binary file modified target/original-JavaDiscordSAILv2.jar
Binary file not shown.

0 comments on commit 03ea29c

Please sign in to comment.