Skip to content

Commit

Permalink
Update maven deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Lindgren committed Jun 6, 2024
1 parent ca5e12d commit b05458d
Show file tree
Hide file tree
Showing 21 changed files with 736 additions and 386 deletions.
73 changes: 47 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>lavalink</id>
<url>https://maven.lavalink.dev/releases</url>
</repository>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
Expand All @@ -35,83 +39,91 @@
<dependency>
<groupId>com.discord4j</groupId>
<artifactId>discord4j-core</artifactId>
<version>3.2.4</version>
<version>3.2.6</version>
</dependency>

<dependency>
<groupId>org.rednoise</groupId>
<artifactId>rita</artifactId>
<version>0.2</version>
<version>2.8.21</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha5</version>
<version>1.5.6</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.16.1</version>
</dependency>


<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.5.1</version>
<version>1.9.0</version>
</dependency>

<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.8.4</version>
<version>3.19.9</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>3.8.4</version>
<version>3.19.9</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>3.8.4</version>
<version>3.19.9</version>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
<version>7.0.0</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1211</version>
<version>42.7.3</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>com.sedmelluq</groupId>
<groupId>com.github.devoxin</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.78</version>
<version>1.9.0</version>
</dependency>

<dependency>
<groupId>dev.lavalink.youtube</groupId>
<artifactId>youtube-plugin</artifactId>
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.3</version>
<version>1.17.2</version>
</dependency>

<dependency>
<groupId>se.michaelthelin.spotify</groupId>
<artifactId>spotify-web-api-java</artifactId>
<version>4.2.1</version>
<version>8.4.0</version>
</dependency>

<dependency>
Expand All @@ -123,19 +135,19 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
<version>3.14.0</version>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev20200402-1.30.9</version>
<version>v3-rev20240514-2.0.0</version>
</dependency>

</dependencies>
Expand Down Expand Up @@ -178,9 +190,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.13.0</version>
<configuration>
<release>22</release>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.16.2</version>
<configuration>
<release>14</release> <!--or <release>10</release>-->
<rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
</configuration>
</plugin>
</plugins>
Expand All @@ -191,12 +212,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.3</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.3</version>
<version>2.17.1</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import com.github.langebangen.kensa.youtube.YoutubeApiService;
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeSearchProvider;
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.*;
import com.wrapper.spotify.SpotifyApi;
import dev.lavalink.youtube.YoutubeAudioSourceManager;
import dev.lavalink.youtube.track.YoutubeAudioTrack;
import discord4j.core.object.entity.Message;
import discord4j.core.object.entity.channel.TextChannel;
import se.michaelthelin.spotify.SpotifyApi;

import java.util.LinkedList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import com.sedmelluq.discord.lavaplayer.source.http.HttpAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.twitch.TwitchStreamAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeSearchProvider;
import com.sedmelluq.discord.lavaplayer.track.playback.NonAllocatingAudioFrameBuffer;
import dev.lavalink.youtube.YoutubeAudioSourceManager;

public class LavaplayerModule
extends AbstractModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import com.google.inject.Singleton;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeSearchProvider;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
import com.wrapper.spotify.SpotifyApi;
import dev.lavalink.youtube.YoutubeAudioSourceManager;
import discord4j.common.util.Snowflake;
import discord4j.core.GatewayDiscordClient;
import discord4j.core.object.presence.ClientActivity;
import discord4j.core.object.presence.ClientPresence;
import se.michaelthelin.spotify.SpotifyApi;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.github.langebangen.kensa.audio.lavaplayer;

import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack;

import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeSearchProvider;
import com.sedmelluq.discord.lavaplayer.track.AudioItem;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioReference;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack;
import com.sedmelluq.discord.lavaplayer.track.*;
import com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor;
import dev.lavalink.youtube.YoutubeAudioSourceManager;
import dev.lavalink.youtube.track.YoutubeAudioTrack;

/**
* Audio track for youtube which will get the best match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import com.neovisionaries.i18n.CountryCode;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeSearchProvider;
import com.sedmelluq.discord.lavaplayer.track.*;
import com.wrapper.spotify.SpotifyApi;
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
import com.wrapper.spotify.model_objects.specification.*;
import dev.lavalink.youtube.YoutubeAudioSourceManager;
import org.apache.hc.core5.http.ParseException;
import se.michaelthelin.spotify.SpotifyApi;
import se.michaelthelin.spotify.exceptions.SpotifyWebApiException;
import se.michaelthelin.spotify.model_objects.specification.*;

import java.io.DataInput;
import java.io.DataOutput;
Expand Down Expand Up @@ -61,12 +62,13 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)
.market(CountryCode.SE)
.build()
.execute();

List<AudioTrack> audioTracks = new LinkedList<>();
int total = Integer.MAX_VALUE;
int offset = 0;
while (total > offset)
{
Paging<PlaylistTrack> playlistTracks = spotifyApi.getPlaylistsTracks(playlistId)
Paging<PlaylistTrack> playlistTracks = spotifyApi.getPlaylistsItems(playlistId)
.market(CountryCode.SE)
.limit(100)
.offset(offset)
Expand All @@ -78,10 +80,12 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)
audioTracks.addAll(Arrays.stream(playlistTracks.getItems())
.map(playlistTrack ->
{
Track track = playlistTrack.getTrack();
var track = playlistTrack.getTrack();

ArtistSimplified[] artists = track.getArtists();
String firstArtistName = artists.length == 0 ? "" : artists[0].getName();
ArtistSimplified[] artists = track instanceof Track t
? t.getArtists()
: new ArtistSimplified[0];
var firstArtistName = artists.length == 0 ? "" : artists[0].getName();

return new YoutubeBestMatchAudioTrack(new AudioTrackInfo(firstArtistName + " - " + track.getName(), firstArtistName,
track.getDurationMs(), "", false, ""),
Expand All @@ -94,7 +98,7 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)

return new BasicAudioPlaylist(playlist.getName() + " by " + playlist.getOwner().getDisplayName(), audioTracks, null, false);
}
catch(IOException | SpotifyWebApiException e)
catch(IOException | SpotifyWebApiException | ParseException e)
{
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.langebangen.kensa.command.Command;
import com.github.langebangen.kensa.listener.event.*;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import discord4j.common.util.Snowflake;
import discord4j.core.GatewayDiscordClient;
import discord4j.core.event.domain.VoiceStateUpdateEvent;
Expand All @@ -23,7 +24,6 @@
import reactor.core.publisher.Mono;
import rita.RiMarkov;

import javax.inject.Named;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
Expand Down Expand Up @@ -281,7 +281,7 @@ private void logMessage(String message)
if(!urlFreeMessage.isEmpty())
{
urlFreeMessage = formatSentence(urlFreeMessage);
markov.loadText(urlFreeMessage);
markov.addText(urlFreeMessage);
try(FileWriter writer = new FileWriter(messageFile, true))
{
writer.write(urlFreeMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import discord4j.core.GatewayDiscordClient;
import discord4j.core.event.domain.message.MessageCreateEvent;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import org.slf4j.Logger;
Expand All @@ -26,8 +25,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

import static com.github.langebangen.kensa.storage.generated.Tables.INSULT;

Expand Down Expand Up @@ -100,7 +97,7 @@ private void onMentionEvent()
.map(guild -> guild.getClient().getSelfId())
.filter(botId -> event.getMessage().getUserMentionIds().contains(botId))
.flatMap(botId -> event.getMessage().getChannel())
.flatMap(channel -> channel.createMessage(markov.generateSentence()))
.flatMap(channel -> channel.createMessage(markov.generate()[0]))
)
.subscribe(null, e -> logger.error("Failed on mention event", e));
}
Expand All @@ -111,16 +108,16 @@ private void onInsultEvent()
.flatMap(event -> {
try(Connection conn = storage.getConnection())
{
DSLContext create = DSL.using(conn, SQLDialect.POSTGRES_9_5);
try(Stream<Record> stream = create.select()
DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
try(var stream = create.select()
.from(INSULT)
.orderBy(DSL.rand())
.stream())
{
Optional<Record> first = stream.findFirst();
var first = stream.findFirst();
if(first.isPresent())
{
Record record = first.get();
var record = first.get();
String text = record.getValue(INSULT.TEXT);
lastInsultId = record.getValue(INSULT.ID);

Expand Down Expand Up @@ -149,9 +146,9 @@ private void onInsultPersistEvent()
.createMessage("No previous insult to remove!");
}

try(Connection conn = storage.getConnection())
try(var conn = storage.getConnection())
{
DSLContext create = DSL.using(conn, SQLDialect.POSTGRES_9_5);
DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
if(event.isAdded())
{
String insult = event.getInsult();
Expand Down
Loading

0 comments on commit b05458d

Please sign in to comment.