diff --git a/src/EllieBot/Modules/Gambling/VoteRewardService.cs b/src/EllieBot/Modules/Gambling/VoteRewardService.cs index aa58da2..3869aca 100644 --- a/src/EllieBot/Modules/Gambling/VoteRewardService.cs +++ b/src/EllieBot/Modules/Gambling/VoteRewardService.cs @@ -1,7 +1,6 @@ using System.Globalization; using Grpc.Core; using EllieBot.Common.ModuleBehaviors; -using EllieBot.GrpcApi; using EllieBot.GrpcVotesApi; namespace EllieBot.Modules.Gambling.Services; @@ -12,7 +11,8 @@ public class VoteRewardService( CurrencyService cs, IBotCache cache, DiscordSocketClient client, - IMessageSenderService sender + IMessageSenderService sender, + IBotCreds creds ) : IEService, IReadyExecutor { private TypedKey<DateTime> VoteKey(ulong userId) @@ -26,6 +26,9 @@ public class VoteRewardService( if (shardData.ShardId != 0) return; + if (creds.Votes is null || creds.Votes.Host is null || creds.Votes.Port == 0) + return; + var serverCreds = ServerCredentials.Insecure; var ssd = VoteService.BindService(new VotesGrpcService(this)); @@ -33,7 +36,7 @@ public class VoteRewardService( { Ports = { - new("127.0.0.1", 59384, serverCreds), + new(creds.Votes.Host, creds.Votes.Port, serverCreds), } }; @@ -44,8 +47,6 @@ public class VoteRewardService( { _voteFeedChannel = await client.GetChannelAsync(cid) as IMessageChannel; } - - return; } public void SetVoiceChannel(IMessageChannel? channel) @@ -118,7 +119,6 @@ public class VoteRewardService( public sealed class VotesGrpcService(VoteRewardService vrs) : VoteService.VoteServiceBase, IEService { - [GrpcNoAuthRequired] public override async Task<GrpcVoteResult> VoteReceived(GrpcVoteData request, ServerCallContext context) { await vrs.UserVotedAsync(ulong.Parse(request.UserId), request.Type); diff --git a/src/EllieBot/_common/Abstractions/creds/IBotCreds.cs b/src/EllieBot/_common/Abstractions/creds/IBotCreds.cs index 83d19b2..c844eb3 100644 --- a/src/EllieBot/_common/Abstractions/creds/IBotCreds.cs +++ b/src/EllieBot/_common/Abstractions/creds/IBotCreds.cs @@ -35,10 +35,10 @@ public interface IBotCreds public interface IVotesSettings { - string TopggServiceUrl { get; set; } - string TopggKey { get; set; } - string DiscordsServiceUrl { get; set; } - string DiscordsKey { get; set; } + string Host { get; set; } + int Port { get; set; } + string DblApiKey { get; set; } + string DiscordsApiKey { get; set; } } public interface IPatreonSettings diff --git a/src/EllieBot/_common/Creds.cs b/src/EllieBot/_common/Creds.cs index 8a76f57..6beecfe 100644 --- a/src/EllieBot/_common/Creds.cs +++ b/src/EllieBot/_common/Creds.cs @@ -6,7 +6,7 @@ namespace EllieBot.Common; public sealed class Creds : IBotCreds { [Comment("""DO NOT CHANGE""")] - public int Version { get; set; } = 20; + public int Version { get; set; } = 21; [Comment("""Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/""")] public string Token { get; set; } @@ -176,7 +176,7 @@ public sealed class Creds : IBotCreds OwnerIds = new List<ulong>(); TotalShards = 1; GoogleApiKey = string.Empty; - Votes = new VotesSettings(string.Empty, string.Empty, string.Empty, string.Empty); + Votes = new VotesSettings(); Patreon = new PatreonSettings(string.Empty, string.Empty, string.Empty, string.Empty); BotListToken = string.Empty; CleverbotApiKey = string.Empty; @@ -246,47 +246,10 @@ public sealed class Creds : IBotCreds public sealed record VotesSettings : IVotesSettings { - [Comment(""" - top.gg votes service url - This is the url of your instance of the EllieBot.Votes api - Example: https://votes.my.cool.bot.com - """)] - public string TopggServiceUrl { get; set; } - - [Comment(""" - Authorization header value sent to the TopGG service url with each request - This should be equivalent to the TopggKey in your EllieBot.Votes api appsettings.json file - """)] - public string TopggKey { get; set; } - - [Comment(""" - discords.com votes service url - This is the url of your instance of the EllieBot.Votes api - Example: https://votes.my.cool.bot.com - """)] - public string DiscordsServiceUrl { get; set; } - - [Comment(""" - Authorization header value sent to the Discords service url with each request - This should be equivalent to the DiscordsKey in your EllieBot.Votes api appsettings.json file - """)] - public string DiscordsKey { get; set; } - - public VotesSettings() - { - } - - public VotesSettings( - string topggServiceUrl, - string topggKey, - string discordsServiceUrl, - string discordsKey) - { - TopggServiceUrl = topggServiceUrl; - TopggKey = topggKey; - DiscordsServiceUrl = discordsServiceUrl; - DiscordsKey = discordsKey; - } + public string Host { get; set; } + public int Port { get; set; } + public string DblApiKey { get; set; } + public string DiscordsApiKey { get; set; } } public sealed record GrpcApiConfig diff --git a/src/EllieBot/_common/Impl/BotCredsProvider.cs b/src/EllieBot/_common/Impl/BotCredsProvider.cs index e57623d..e43bc0b 100644 --- a/src/EllieBot/_common/Impl/BotCredsProvider.cs +++ b/src/EllieBot/_common/Impl/BotCredsProvider.cs @@ -133,9 +133,9 @@ public sealed class BotCredsProvider : IBotCredsProvider if (File.Exists(CREDS_FILE_NAME)) { var creds = Yaml.Deserializer.Deserialize<Creds>(File.ReadAllText(CREDS_FILE_NAME)); - if (creds.Version < 20) + if (creds.Version < 21) { - creds.Version = 20; + creds.Version = 21; File.WriteAllText(CREDS_FILE_NAME, Yaml.Serializer.Serialize(creds)); } }