Skip to content

Commit bf71f6c

Browse files
committed
Merge branch 'master' into feature/jda4
2 parents e2b8bbc + fe7cac7 commit bf71f6c

File tree

18 files changed

+321
-171
lines changed

18 files changed

+321
-171
lines changed

lists/copypastas.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftl
2525
Shrek || years old && is love && is life && spread && push against && straight in the
2626

2727
// Scams
28-
Fake Libra Site || getlⅰbra.tech
28+
Fake Libra Site || getlⅰbra.tech
29+
Fake Libra Site (2) || buylⅰbra.τech

src/main/java/com/jagrosh/vortex/Constants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public class Constants
4444
// public final static String BOT_INVITE = "https://discordapp.com/oauth2/authorize?client_id=169463754382114816&scope=bot&permissions="+Permission.getRaw(PERMISSIONS);
4545
public final static String OWNER_ID = "113156185389092864";
4646
public final static String DONATION_LINK = "https://patreon.com/jagrosh";
47-
public final static String NEED_PRO = WARNING + " Sorry, this feature requires Vortex Pro. Vortex Pro is not available yet.";
4847

4948
public final static class Wiki
5049
{
50+
public final static String PRIMARY_LINK = "https://jagrosh.com/vortex";
51+
5152
public final static String SHORT_WIKI = "https://git.io/fxHam";
5253
public final static String SHORT_COMMANDS = "https://git.io/vAr0G";
5354

src/main/java/com/jagrosh/vortex/Vortex.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import com.typesafe.config.ConfigFactory;
4747
import java.util.EnumSet;
4848
import java.util.concurrent.TimeUnit;
49+
import net.dv8tion.jda.api.JDA;
50+
import net.dv8tion.jda.api.JDABuilder;
4951
import net.dv8tion.jda.api.entities.Activity;
5052
import net.dv8tion.jda.api.entities.ChannelType;
5153
import net.dv8tion.jda.api.exceptions.PermissionException;
@@ -71,27 +73,29 @@ public class Vortex
7173
private final AutoMod automod;
7274
private final StrikeHandler strikehandler;
7375
private final CommandExceptionListener listener;
76+
private final JDA altBot;
7477

7578
public Vortex() throws Exception
7679
{
7780
System.setProperty("config.file", System.getProperty("config.file", "application.conf"));
7881
Config config = ConfigFactory.load();
82+
altBot = new JDABuilder(config.getString("alt-token")).build();
7983
waiter = new EventWaiter(Executors.newSingleThreadScheduledExecutor(), false);
80-
threadpool = Executors.newScheduledThreadPool(50);
84+
threadpool = Executors.newScheduledThreadPool(100);
8185
database = new Database(config.getString("database.host"),
8286
config.getString("database.username"),
8387
config.getString("database.password"));
84-
uploader = new TextUploader(this, config.getLong("uploader.guild"), config.getLong("uploader.category"));
88+
uploader = new TextUploader(altBot, config.getLong("uploader.guild"), config.getLong("uploader.category"));
8589
modlog = new ModLogger(this);
8690
basiclog = new BasicLogger(this, config);
8791
messages = new MessageCache();
8892
logwebhook = new WebhookClientBuilder(config.getString("webhook-url")).build();
89-
automod = new AutoMod(this, config);
93+
automod = new AutoMod(this, altBot, config);
9094
strikehandler = new StrikeHandler(this);
9195
listener = new CommandExceptionListener();
9296
CommandClient client = new CommandClientBuilder()
9397
.setPrefix(Constants.PREFIX)
94-
.setActivity(Activity.playing(Constants.Wiki.SHORT_WIKI))
98+
.setActivity(Activity.playing(Constants.Wiki.PRIMARY_LINK))
9599
.setOwnerId(Constants.OWNER_ID)
96100
.setServerInvite(Constants.SERVER_INVITE)
97101
.setEmojis(Constants.SUCCESS, Constants.WARNING, Constants.ERROR)
@@ -268,6 +272,7 @@ public void cleanPremium()
268272
{
269273
database.automod.setResolveUrls(gid, false);
270274
database.settings.setAvatarLogChannel(gid, null);
275+
database.settings.setVoiceLogChannel(gid, null);
271276
database.filters.deleteAllFilters(gid);
272277
});
273278
}

src/main/java/com/jagrosh/vortex/automod/AutoMod.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.regex.Matcher;
3838
import java.util.regex.Pattern;
3939
import java.util.stream.Collectors;
40+
import net.dv8tion.jda.api.JDA;
4041
import net.dv8tion.jda.api.Permission;
4142
import net.dv8tion.jda.api.entities.*;
4243
import net.dv8tion.jda.api.entities.Guild.VerificationLevel;
@@ -68,16 +69,17 @@ public class AutoMod
6869

6970
private String[] refLinkList;
7071
private final URLResolver urlResolver;
71-
private final InviteResolver inviteResolver = new InviteResolver();
72+
private final InviteResolver inviteResolver;
7273
private final CopypastaResolver copypastaResolver = new CopypastaResolver();
7374
private final FixedCache<String,DupeStatus> spams = new FixedCache<>(3000);
7475
private final HashMap<Long,OffsetDateTime> latestGuildJoin = new HashMap<>();
7576
private final Usage usage = new Usage();
7677

77-
public AutoMod(Vortex vortex, Config config)
78+
public AutoMod(Vortex vortex, JDA altBot, Config config)
7879
{
7980
this.vortex = vortex;
80-
urlResolver = config.getBoolean("url-resolver.active") ? new ActiveURLResolver(config) : new DummyURLResolver();
81+
this.inviteResolver = new InviteResolver(altBot);
82+
this.urlResolver = config.getBoolean("url-resolver.active") ? new ActiveURLResolver(config) : new DummyURLResolver();
8183
loadCopypastas();
8284
loadReferralDomains();
8385
}
@@ -432,7 +434,7 @@ else if(offenses>settings.dupeDeleteThresh)
432434
for(String inviteCode : invites)
433435
{
434436
LOG.info("Resolving invite in " + message.getGuild().getId() + ": " + inviteCode);
435-
long gid = inviteResolver.resolve(message.getJDA(), inviteCode);
437+
long gid = inviteResolver.resolve(inviteCode);
436438
if(gid != message.getGuild().getIdLong() && !inviteWhitelist.contains(gid))
437439
{
438440
strikeTotal += settings.inviteStrikes;
@@ -491,7 +493,7 @@ else if(offenses>settings.dupeDeleteThresh)
491493
{
492494
String code = resolved.replaceAll(INVITE_LINK, "$1");
493495
LOG.info("Delayed resolving invite in " + message.getGuild().getId() + ": " + code);
494-
long invite = inviteResolver.resolve(message.getJDA(), code);
496+
long invite = inviteResolver.resolve(code);
495497
if(invite != message.getGuild().getIdLong() && !inviteWhitelist.contains(invite))
496498
containsInvite = true;
497499
}

src/main/java/com/jagrosh/vortex/automod/InviteResolver.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@
2727
*/
2828
public class InviteResolver
2929
{
30+
private final JDA altBot;
3031
private final Logger log = LoggerFactory.getLogger(InviteResolver.class);
3132
private final FixedCache<String,Long> cached = new FixedCache<>(5000);
3233

33-
public long resolve(JDA jda, String code)
34+
public InviteResolver(JDA altBot)
35+
{
36+
this.altBot = altBot;
37+
}
38+
39+
public long resolve(String code)
3440
{
3541
log.debug("Attempting to resolve " + code);
3642
if(cached.contains(code))
3743
return cached.get(code);
3844
try
3945
{
40-
Invite i = Invite.resolve(jda, code).complete(false);
46+
Invite i = Invite.resolve(altBot, code).complete(false);
4147
cached.put(code, i.getGuild().getIdLong());
4248
return i.getGuild().getIdLong();
4349
}

src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected void execute(CommandEvent event)
8181
{
8282
if(!vortex.getDatabase().premium.getPremiumInfo(event.getGuild()).level.isAtLeast(PremiumManager.Level.PRO))
8383
{
84-
event.reply(Constants.NEED_PRO);
84+
event.reply(PremiumManager.Level.PRO.getRequirementMessage());
8585
return;
8686
}
8787

src/main/java/com/jagrosh/vortex/commands/automod/ResolvelinksCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected void execute(CommandEvent event)
5353
event.replySuccess("Link Resolving has been turned `"+event.getArgs().toUpperCase()+"`");
5454
}
5555
else
56-
event.reply(Constants.NEED_PRO);
56+
event.reply(PremiumManager.Level.PRO.getRequirementMessage());
5757
}
5858
else
5959
{
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2020 John Grosh ([email protected]).
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.jagrosh.vortex.commands.owner;
17+
18+
import com.jagrosh.jdautilities.command.Command;
19+
import com.jagrosh.jdautilities.command.CommandEvent;
20+
import com.jagrosh.vortex.Vortex;
21+
import net.dv8tion.jda.api.Permission;
22+
import org.json.JSONObject;
23+
24+
/**
25+
*
26+
* @author John Grosh ([email protected])
27+
*/
28+
public class ExportCmd extends Command
29+
{
30+
private final Vortex vortex;
31+
32+
public ExportCmd(Vortex vortex)
33+
{
34+
this.vortex = vortex;
35+
this.name = "export";
36+
this.arguments = "<serverid>";
37+
this.help = "exports all server data as json";
38+
this.category = new Category("Tools");
39+
this.userPermissions = new Permission[]{Permission.MESSAGE_ATTACH_FILES};
40+
this.ownerCommand = true;
41+
}
42+
43+
@Override
44+
protected void execute(CommandEvent event)
45+
{
46+
long gid;
47+
try
48+
{
49+
gid = Long.parseLong(event.getArgs());
50+
}
51+
catch(NumberFormatException ex)
52+
{
53+
event.reactError();
54+
return;
55+
}
56+
JSONObject obj = new JSONObject();
57+
58+
}
59+
}

src/main/java/com/jagrosh/vortex/commands/settings/AvatarlogCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ protected void setLogChannel(CommandEvent event, TextChannel tc)
5858
event.replySuccess("Avatar Logs will now be sent in "+tc.getAsMention());
5959
}
6060
else
61-
event.reply(Constants.NEED_PRO);
61+
event.reply(PremiumManager.Level.PRO.getRequirementMessage());
6262
}
6363
}

src/main/java/com/jagrosh/vortex/commands/settings/VoicelogCmd.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.jagrosh.jdautilities.command.CommandEvent;
1919
import com.jagrosh.vortex.Vortex;
2020
import com.jagrosh.vortex.commands.LogCommand;
21+
import com.jagrosh.vortex.database.managers.PremiumManager;
2122
import net.dv8tion.jda.api.entities.TextChannel;
2223

2324
/**
@@ -47,10 +48,15 @@ protected void showCurrentChannel(CommandEvent event)
4748
@Override
4849
protected void setLogChannel(CommandEvent event, TextChannel tc)
4950
{
50-
vortex.getDatabase().settings.setVoiceLogChannel(event.getGuild(), tc);
51-
if(tc==null)
52-
event.replySuccess("Voice Logs will not be sent");
51+
if(vortex.getDatabase().premium.getPremiumInfo(event.getGuild()).level.isAtLeast(PremiumManager.Level.PLUS))
52+
{
53+
vortex.getDatabase().settings.setVoiceLogChannel(event.getGuild(), tc);
54+
if(tc==null)
55+
event.replySuccess("Voice Logs will not be sent");
56+
else
57+
event.replySuccess("Voice Logs will now be sent in "+tc.getAsMention());
58+
}
5359
else
54-
event.replySuccess("Voice Logs will now be sent in "+tc.getAsMention());
60+
event.reply(PremiumManager.Level.PLUS.getRequirementMessage());
5561
}
5662
}

0 commit comments

Comments
 (0)