Skip to content

Commit c59c94c

Browse files
authored
Merge pull request #386 from KittyBot-Org/development
fixes & new filters
2 parents 818aa91 + 6689ef2 commit c59c94c

File tree

9 files changed

+97
-26
lines changed

9 files changed

+97
-26
lines changed

build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
id 'application'
44
id 'com.github.johnrengelman.shadow' version '7.0.0'
5-
id 'nu.studer.jooq' version '5.2.2'
5+
id 'nu.studer.jooq' version '6.0'
66
}
77

88
group 'de.kittybot'
@@ -17,25 +17,25 @@ repositories {
1717

1818
dependencies {
1919
// discord/jda related
20-
implementation('net.dv8tion:JDA:4.3.0_289') {
20+
implementation('net.dv8tion:JDA:4.3.0_298') {
2121
exclude group: 'club.minnced', module: 'opus-java'
2222
}
2323
implementation 'com.jagrosh:jda-utilities:3.0.5'
2424
implementation 'club.minnced:discord-webhooks:0.5.7'
25-
implementation 'dev.mlnr:BotListHandler-jda:2.0.0_7'
25+
implementation 'dev.mlnr:BotListHandler-jda:2.0.0_8'
2626

2727
// audio
28-
implementation('com.github.KittyBot-Org:Lavalink-Client:176ca86') {
28+
implementation('com.github.KittyBot-Org:Lavalink-Client:d48f1a6') {
2929
exclude group: 'com.sedmelluq', module: 'lavaplayer'
3030
}
3131
implementation 'com.sedmelluq:lavaplayer:1.3.78'
3232
implementation 'se.michaelthelin.spotify:spotify-web-api-java:6.5.4'
3333

3434
// database
35-
implementation 'com.zaxxer:HikariCP:4.0.3'
36-
implementation 'org.jooq:jooq:3.14.12'
37-
implementation 'org.postgresql:postgresql:42.2.22'
38-
jooqGenerator 'org.postgresql:postgresql:42.2.22'
35+
implementation 'com.zaxxer:HikariCP:5.0.0'
36+
implementation 'org.jooq:jooq:3.15.1'
37+
implementation 'org.postgresql:postgresql:42.2.23'
38+
jooqGenerator 'org.postgresql:postgresql:42.2.23'
3939

4040
// logging
4141
implementation 'ch.qos.logback:logback-classic:1.3.0-alpha5'
@@ -55,8 +55,8 @@ dependencies {
5555
implementation 'io.prometheus:simpleclient_httpserver:0.11.0'
5656

5757
// other
58-
implementation 'io.javalin:javalin:3.13.8'
59-
implementation 'io.github.classgraph:classgraph:4.8.109'
58+
implementation 'io.javalin:javalin:3.13.10'
59+
implementation 'io.github.classgraph:classgraph:4.8.110'
6060
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.3'
6161
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
6262
}

src/main/java/de/kittybot/kittybot/commands/dev/EvalCommand.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
import de.kittybot.kittybot.slashcommands.interaction.Interaction;
88
import de.kittybot.kittybot.slashcommands.interaction.Options;
99
import de.kittybot.kittybot.slashcommands.interaction.response.FollowupMessage;
10-
import de.kittybot.kittybot.slashcommands.interaction.response.InteractionResponse;
11-
import de.kittybot.kittybot.slashcommands.interaction.response.InteractionResponseType;
12-
import de.kittybot.kittybot.utils.Colors;
13-
import net.dv8tion.jda.api.EmbedBuilder;
1410

1511
import javax.script.ScriptEngine;
1612
import javax.script.ScriptEngineManager;

src/main/java/de/kittybot/kittybot/commands/music/FilterCommand.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public FilterCommand(){
2424
new VibratoCommand(),
2525
new RotationCommand(),
2626
new DistortionCommand(),
27+
new ChannelMixCommand(),
28+
new LowPassCommand(),
2729
new ClearCommand()
2830
);
2931
}
@@ -262,6 +264,70 @@ public void run(Options options, GuildInteraction ia){
262264

263265
}
264266

267+
private static class ChannelMixCommand extends GuildSubCommand{
268+
269+
public ChannelMixCommand(){
270+
super("channel-mix", "Mixes both channels, with a configurable factor on how much each channel affects the other.");
271+
addOptions(
272+
new CommandOptionFloat("left-to-left", "How much audio from the left channel goes to the left channel"),
273+
new CommandOptionFloat("left-to-right", "How much audio from the left channel goes to the right channel"),
274+
new CommandOptionFloat("right-to-left", "How much audio from the right channel goes to the left channel"),
275+
new CommandOptionFloat("right-to-right", "How much audio from the right channel goes to the right channel")
276+
);
277+
}
278+
279+
@Override
280+
public void run(Options options, GuildInteraction ia){
281+
var scheduler = ia.get(MusicModule.class).getScheduler(ia.getGuildId());
282+
if(!MusicUtils.checkCommandRequirements(ia, scheduler) || !MusicUtils.checkMusicPermissions(ia, scheduler)){
283+
return;
284+
}
285+
var channelMix = new ChannelMix();
286+
if(options.has("left-to-left")){
287+
channelMix = channelMix.setLeftToLeft(options.getFloat("left-to-left"));
288+
}
289+
if(options.has("left-to-right")){
290+
channelMix = channelMix.setLeftToRight(options.getFloat("left-to-right"));
291+
}
292+
if(options.has("right-to-left")){
293+
channelMix = channelMix.setRightToLeft(options.getFloat("right-to-left"));
294+
}
295+
if(options.has("right-to-right")){
296+
channelMix = channelMix.setRightToLeft(options.getFloat("right-to-right"));
297+
}
298+
299+
scheduler.getFilters().setChannelMix(channelMix).commit();
300+
ia.reply("Set channel-mix filter");
301+
}
302+
303+
}
304+
305+
private static class LowPassCommand extends GuildSubCommand{
306+
307+
public LowPassCommand(){
308+
super("low-pass", "Higher frequencies get suppressed, while lower frequencies pass through this filter.");
309+
addOptions(
310+
new CommandOptionFloat("smoothing", "The smoothing level")
311+
);
312+
}
313+
314+
@Override
315+
public void run(Options options, GuildInteraction ia){
316+
var scheduler = ia.get(MusicModule.class).getScheduler(ia.getGuildId());
317+
if(!MusicUtils.checkCommandRequirements(ia, scheduler) || !MusicUtils.checkMusicPermissions(ia, scheduler)){
318+
return;
319+
}
320+
var lowPass = new LowPass();
321+
if(options.has("smoothing")){
322+
lowPass = lowPass.setSmoothing(options.getFloat("smoothing"));
323+
}
324+
325+
scheduler.getFilters().setLowPass(lowPass).commit();
326+
ia.reply("Set low-pass filter");
327+
}
328+
329+
}
330+
265331
private static class ClearCommand extends GuildSubCommand{
266332

267333
public ClearCommand(){

src/main/java/de/kittybot/kittybot/main/KittyBot.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public KittyBot() throws IOException, MissingConfigValuesException, LoginExcepti
3737
.addBotList(BotList.TOP_GG, Config.TOP_GG_TOKEN)
3838
.addBotList(BotList.DBOATS, Config.DISCORD_BOATS_TOKEN)
3939
.addBotList(BotList.DISCORDLIST_SPACE, Config.BOTLIST_SPACE_TOKEN)
40-
.addBotList(BotList.BOTS_FOR_DISCORD, Config.BOTS_FOR_DISCORD_TOKEN)
4140
.addBotList(BotList.DSERVICES, Config.DISCORD_SERVICES_TOKEN)
4241
.addBotList(BotList.DBL, Config.DISCORD_BOT_LIST_TOKEN)
4342
.addBotList(BotList.DEL, Config.DISCORD_EXTREME_LIST_TOKEN)

src/main/java/de/kittybot/kittybot/modules/AnnouncementModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
1212
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
1313
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
14-
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
15-
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
1614
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
1715
import org.jetbrains.annotations.NotNull;
1816
import org.slf4j.Logger;

src/main/java/de/kittybot/kittybot/modules/GuildLoggingModule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import javax.annotation.Nonnull;
1515
import java.awt.Color;
16-
import java.text.MessageFormat;
1716
import java.time.Instant;
1817
import java.util.Set;
1918

src/main/java/de/kittybot/kittybot/modules/StreamModule.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ private void checkTwitch(){
7171
if(userIds.isEmpty()){
7272
return;
7373
}
74-
var streams = this.twitchWrapper.getStreams(userIds, false);
74+
var streams = this.twitchWrapper.getStreams(userIds);
7575

7676
for(var streamAnnouncement : this.streams){
7777
var stream = streams.stream().filter(st -> st.getUserId() == streamAnnouncement.getUserId()).findFirst();
78+
if(stream.isPresent() && stream.get().hasError()){
79+
// error while fetching stream skip
80+
continue;
81+
}
7882
if(stream.isPresent() && !streamAnnouncement.getIsLive()){
7983
setLiveStatus(streamAnnouncement, true);
8084
// send online
@@ -133,7 +137,7 @@ private void sendAnnouncementMessage(StreamUsersRecord streamAnnouncement, Strea
133137
break;
134138
}
135139
channel.sendMessage(settings.getStreamAnnouncementMessage().replace("${user}", stream.getUserName()))
136-
.embed(embed
140+
.setEmbeds(embed
137141
.setTimestamp(Instant.now())
138142
.setColor(Colors.TWITCH_PURPLE)
139143
.build()

src/main/java/de/kittybot/kittybot/objects/streams/Stream.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ public class Stream{
1515
private final Instant startedAt;
1616
private final Language language;
1717
private final StreamType type;
18+
private final boolean error;
1819
private Game game;
1920

20-
public Stream(long streamId, String streamTitle, String thumbnailUrl, long userId, String userName, Game game, int viewerCount, Instant startedAt, Language language, StreamType type){
21+
public Stream(long streamId, String streamTitle, String thumbnailUrl, long userId, String userName, Game game, int viewerCount, Instant startedAt, Language language, StreamType type, boolean error){
2122
this.streamId = streamId;
2223
this.streamTitle = streamTitle;
2324
this.thumbnailUrl = thumbnailUrl;
@@ -28,6 +29,7 @@ public Stream(long streamId, String streamTitle, String thumbnailUrl, long userI
2829
this.startedAt = startedAt;
2930
this.language = language;
3031
this.type = type;
32+
this.error = error;
3133
}
3234

3335
public static Stream fromTwitchJSON(DataObject json){
@@ -42,7 +44,8 @@ public static Stream fromTwitchJSON(DataObject json){
4244
json.getInt("viewer_count"),
4345
Instant.parse(json.getString("started_at")),
4446
lang.orElse(Language.UNKNOWN),
45-
StreamType.TWITCH
47+
StreamType.TWITCH,
48+
false
4649
);
4750
}
4851

@@ -100,4 +103,8 @@ public String getStreamUrl(){
100103
return null;
101104
}
102105

106+
public boolean hasError(){
107+
return this.error;
108+
}
109+
103110
}

src/main/java/de/kittybot/kittybot/objects/streams/twitch/TwitchWrapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package de.kittybot.kittybot.objects.streams.twitch;
22

33
import de.kittybot.kittybot.objects.streams.BearerToken;
4+
import de.kittybot.kittybot.objects.streams.Game;
45
import de.kittybot.kittybot.objects.streams.Stream;
6+
import de.kittybot.kittybot.objects.streams.StreamType;
57
import net.dv8tion.jda.api.utils.data.DataObject;
68
import okhttp3.Call;
79
import okhttp3.FormBody;
@@ -100,7 +102,7 @@ private Call newRequest(String url, Object... params){
100102
);
101103
}
102104

103-
public List<Stream> getStreams(List<Long> userIds, boolean reTry){
105+
public List<Stream> getStreams(List<Long> userIds){
104106
var streams = new ArrayList<Stream>();
105107
do{
106108
var users = userIds.subList(0, Math.min(userIds.size(), 100));
@@ -112,9 +114,9 @@ public List<Stream> getStreams(List<Long> userIds, boolean reTry){
112114
LOG.error("Url: {} Code: {} Body: {}", resp.request().url(), resp.code(), body == null ? "null" : body.string());
113115
if(resp.code() == 401){
114116
this.bearerToken = null;
115-
if(!reTry){
116-
return getStreams(userIds, true);
117-
}
117+
}
118+
for(var userId : users){
119+
streams.add(new Stream(0L, "", "", userId, "", Game.getUnknown(), 0, null, null, StreamType.YOUTUBE, true));
118120
}
119121
continue;
120122
}

0 commit comments

Comments
 (0)