Compare commits
No commits in common. "97fe14cf5a9c7c3d4ca220db4d26a2c79d02de23" and "9fe75d930f841d032ee9c70c14cbc7b7a1423f5a" have entirely different histories.
97fe14cf5a
...
9fe75d930f
11 changed files with 72 additions and 162 deletions
src
EllieBot.VotesApi
EllieBot
Modules
data
strings
|
@ -25,7 +25,8 @@ namespace EllieBot.VotesApi
|
|||
|
||||
services.AddGrpcClient<VoteService.VoteServiceClient>(options =>
|
||||
{
|
||||
options.Address = new Uri("http://127.0.0.1:59384");
|
||||
var grpcServiceUrl = Configuration["GrpcServiceUrl"]!;
|
||||
options.Address = new Uri(grpcServiceUrl);
|
||||
})
|
||||
.ConfigureChannel((sp, c) =>
|
||||
{
|
||||
|
|
|
@ -167,49 +167,15 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
|
||||
var (amount, msg) = await _service.GetAmountAndMessage(ctx.User.Id, reward);
|
||||
|
||||
var prepend = GetText(strs.vote_suggest(Format.Bold(N(amount))));
|
||||
var prepend = GetText(strs.vote_suggest(N(amount)));
|
||||
msg = prepend + "\n\n" + msg;
|
||||
|
||||
var inter = CreateRemindMeInteraction(6) as EllieButtonInteractionHandler;
|
||||
var eb = CreateEmbed()
|
||||
.WithOkColor()
|
||||
.WithDescription(msg);
|
||||
var inter = CreateRemindMeInteraction(6);
|
||||
|
||||
var cb = new ComponentBuilder();
|
||||
|
||||
// Add vote platform buttons if any are configured
|
||||
if (Config.VotePlatforms.Length > 0)
|
||||
{
|
||||
var row = new ActionRowBuilder();
|
||||
// Loop through each vote platform and create a URL button for it
|
||||
foreach (var platform in Config.VotePlatforms)
|
||||
{
|
||||
// Create a URL button for each platform
|
||||
// The platform string should be in format "Label|URL"
|
||||
var parts = platform.Split('|', 2);
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
var label = parts[0];
|
||||
var url = parts[1];
|
||||
|
||||
// Add a URL button to the component builder
|
||||
row.WithButton(label, style: ButtonStyle.Link, url: url);
|
||||
}
|
||||
}
|
||||
cb.AddRow(row);
|
||||
}
|
||||
if (!_service.UserHasTimelyReminder(ctx.User.Id))
|
||||
{
|
||||
var secondRow = new ActionRowBuilder();
|
||||
secondRow.WithButton(inter.Button);
|
||||
cb.AddRow(secondRow);
|
||||
var sent = await ctx.Channel.SendMessageAsync(embed: eb.Build(), components: cb?.Build());
|
||||
await inter.RunAsync(sent);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.Channel.SendMessageAsync(embed: eb.Build(), components: cb?.Build());
|
||||
}
|
||||
await Response()
|
||||
.Confirm(msg)
|
||||
.Interaction(inter)
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
|
@ -249,10 +215,10 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
var toSend = Response()
|
||||
.File(stream, "timely.png");
|
||||
|
||||
#if GLOBAL_ELLIE
|
||||
#if GLOBAL_NADEKO
|
||||
if (_rng.Next(0, 8) == 0)
|
||||
toSend = toSend
|
||||
.Text("*[Sub on Patreon](https://patreon.com/elliebot) to remove captcha.*");
|
||||
.Text("*[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha.*");
|
||||
#endif
|
||||
|
||||
var captchaMessage = await toSend.SendAsync();
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace EllieBot.Modules.Gambling.Common;
|
|||
public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||
{
|
||||
[Comment("""DO NOT CHANGE""")]
|
||||
public int Version { get; set; } = 13;
|
||||
public int Version { get; set; } = 12;
|
||||
|
||||
[Comment("""Currency settings""")]
|
||||
public CurrencyConfig Currency { get; set; }
|
||||
|
@ -68,15 +68,6 @@ public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
|||
Id of the channel to send a message to after a user votes
|
||||
""")]
|
||||
public ulong? VoteFeedChannelId { get; set; }
|
||||
|
||||
[Comment("""
|
||||
List of platforms for which the bot will give currency rewards.
|
||||
Format: PLATFORM|URL
|
||||
Supported platforms: topgg, discords, discordbotlist
|
||||
You will have to have VotesApi running on the same machine.
|
||||
Format example: Top.gg|https://top.gg/bot/YOUR_BOT_ID/vote
|
||||
""")]
|
||||
public string[] VotePlatforms { get; set; } = [];
|
||||
|
||||
[Comment("""Slot config""")]
|
||||
public SlotsConfig Slots { get; set; }
|
||||
|
|
|
@ -12,6 +12,12 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
|||
public override string Name
|
||||
=> "gambling";
|
||||
|
||||
private readonly IEnumerable<WaifuItemModel> _antiGiftSeed = new[]
|
||||
{
|
||||
new WaifuItemModel("🥀", 100, "WiltedRose", true), new WaifuItemModel("✂️", 1000, "Haircut", true),
|
||||
new WaifuItemModel("🧻", 10000, "ToiletPaper", true)
|
||||
};
|
||||
|
||||
public GamblingConfigService(IConfigSeria serializer, IPubSub pubSub)
|
||||
: base(FILE_PATH, serializer, pubSub, _changeKey)
|
||||
{
|
||||
|
@ -148,12 +154,51 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
|||
|
||||
public void Migrate()
|
||||
{
|
||||
if (data.Version < 13)
|
||||
if (data.Version < 2)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 13;
|
||||
c.VotePlatforms = [];
|
||||
c.Waifu.Items = c.Waifu.Items.Concat(_antiGiftSeed).ToList();
|
||||
c.Version = 2;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 3)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 3;
|
||||
c.VoteReward = 100;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 7)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 7;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 8)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 8;
|
||||
c.Waifu.Decay.UnclaimedDecayPercent = 0;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 12)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 12;
|
||||
|
||||
if (c.BetRoll.Pairs.Length == 3 && c.BetRoll.Pairs[2].WhenAbove == 66)
|
||||
{
|
||||
c.BetRoll.Pairs[2].WhenAbove = 65;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class GamblingService : IEService, IReadyExecutor
|
|||
}
|
||||
}
|
||||
|
||||
private static readonly TypedKey<EconomyResult> _ecoKey = new("ellie:economy");
|
||||
private static readonly TypedKey<EconomyResult> _ecoKey = new("nadeko:economy");
|
||||
|
||||
private static readonly SemaphoreSlim _timelyLock = new(1, 1);
|
||||
|
||||
|
@ -235,22 +235,22 @@ public class GamblingService : IEService, IReadyExecutor
|
|||
|
||||
originalAmount += (int)(originalAmount * percentBonus);
|
||||
|
||||
var msg = $"**{N(originalAmount)}** base reward\n\n";
|
||||
var msg = $"{N(originalAmount)} base reward.\n";
|
||||
if (boostGuilds.Count > 0)
|
||||
{
|
||||
if (booster)
|
||||
msg += $"\\✅ *+{N(gcsData.BoostBonus.BaseTimelyBonus)} bonus for boosting {userInfo.guild}!*\n";
|
||||
msg += $"✅ *+{N(gcsData.BoostBonus.BaseTimelyBonus)} bonus for boosting {userInfo.guild}!*\n";
|
||||
else
|
||||
msg += $"\\❌ *+0 bonus for boosting {userInfo.guild}*\n";
|
||||
msg += $"❌ +0 bonus for boosting {userInfo.guild}.\n";
|
||||
}
|
||||
|
||||
if (_ps.GetConfig().IsEnabled)
|
||||
{
|
||||
if (percentBonus > float.Epsilon)
|
||||
msg +=
|
||||
$"\\✅ *+{percentBonus:P0} bonus for the [Patreon](https://patreon.com/elliebot) pledge! <:hart:746995901758832712>*\n";
|
||||
$"✅ *+{percentBonus:P0} bonus for the [Patreon](https://patreon.com/nadekobot) pledge! <:hart:746995901758832712>*";
|
||||
else
|
||||
msg += $"\\❌ *+0 bonus for the [Patreon](https://patreon.com/elliebot) pledge*\n";
|
||||
msg += $"❌ +0 bonus for the [Patreon](https://patreon.com/nadekobot) pledge.";
|
||||
}
|
||||
|
||||
return (originalAmount, msg);
|
||||
|
|
|
@ -11,42 +11,4 @@ public class Owner(VoteRewardService vrs) : EllieModule
|
|||
vrs.SetVoiceChannel(ctx.Channel);
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
private static CancellationTokenSource _cts = null;
|
||||
|
||||
[Cmd]
|
||||
public async Task MassPing()
|
||||
{
|
||||
if (_cts is { } t)
|
||||
{
|
||||
await t.CancelAsync();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var users = await ctx.Guild.GetUsersAsync().Fmap(u => u.Where(x => !x.IsBot).ToArray());
|
||||
|
||||
var currentIndex = 0;
|
||||
while (!_cts.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var batch = users[currentIndex..(currentIndex += 50)];
|
||||
|
||||
var mentions = batch.Select(x => x.Mention).Join(" ");
|
||||
await ctx.Channel.SendMessageAsync(mentions, allowedMentions: AllowedMentions.All);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
await Task.Delay(2500);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cts = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -974,7 +974,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"ManageRoles Server Permission"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -991,7 +991,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"ManageRoles Server Permission"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1007,7 +1007,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"ManageRoles Server Permission"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1025,7 +1025,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"ManageRoles Server Permission"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -2990,19 +2990,6 @@
|
|||
}
|
||||
],
|
||||
"Gambling": [
|
||||
{
|
||||
"Aliases": [
|
||||
".vote"
|
||||
],
|
||||
"Description": "Shows instructions for voting for the bot in order to get rewards.\nWill redirect user to timely if voting is not enabled.",
|
||||
"Usage": [
|
||||
".vote"
|
||||
],
|
||||
"Submodule": "Gambling",
|
||||
"Module": "Gambling",
|
||||
"Options": null,
|
||||
"Requirements": []
|
||||
},
|
||||
{
|
||||
"Aliases": [
|
||||
".timely"
|
||||
|
@ -5224,22 +5211,6 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"Owner": [
|
||||
{
|
||||
"Aliases": [
|
||||
".votefeed"
|
||||
],
|
||||
"Description": "Shows bot votes in real time in the specified channel.\nOmit channel to disable.",
|
||||
"Usage": [
|
||||
".votefeed #votefeed",
|
||||
".votefeed"
|
||||
],
|
||||
"Submodule": "Owner",
|
||||
"Module": "Owner",
|
||||
"Options": null,
|
||||
"Requirements": []
|
||||
}
|
||||
],
|
||||
"Permissions": [
|
||||
{
|
||||
"Aliases": [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# DO NOT CHANGE
|
||||
version: 13
|
||||
version: 12
|
||||
# Currency settings
|
||||
currency:
|
||||
# What is the emoji/character which represents the currency
|
||||
|
@ -270,14 +270,6 @@ patreonCurrencyPerCent: 1
|
|||
# Currency reward per vote.
|
||||
# This will work only if you've set up VotesApi and correct credentials for topgg and/or discords voting
|
||||
voteReward: 100
|
||||
# Id of the channel to send a message to after a user votes
|
||||
voteFeedChannelId:
|
||||
# List of platforms for which the bot will give currency rewards.
|
||||
# Format: PLATFORM|URL
|
||||
# Supported platforms: topgg, discords, discordbotlist
|
||||
# You will have to have VotesApi running on the same machine.
|
||||
# Format example: Top.gg|https://top.gg/bot/YOUR_BOT_ID/vote
|
||||
votePlatforms: []
|
||||
# Slot config
|
||||
slots:
|
||||
# Hex value of the color which the numbers on the slot image will have.
|
||||
|
|
|
@ -1656,6 +1656,4 @@ linkfixlist:
|
|||
votefeed:
|
||||
- votefeed
|
||||
vote:
|
||||
- vote
|
||||
massping:
|
||||
- massping
|
||||
- vote
|
|
@ -5190,21 +5190,5 @@ votefeed:
|
|||
ex:
|
||||
- '#votefeed'
|
||||
- ''
|
||||
params:
|
||||
- { }
|
||||
vote:
|
||||
desc: |-
|
||||
Shows instructions for voting for the bot in order to get rewards.
|
||||
Will redirect user to timely if voting is not enabled.
|
||||
ex:
|
||||
- ''
|
||||
params:
|
||||
- { }
|
||||
massping:
|
||||
desc: |-
|
||||
Mass pings all users in the server.
|
||||
Run again to cancel.
|
||||
ex:
|
||||
- ''
|
||||
params:
|
||||
- { }
|
|
@ -1243,6 +1243,6 @@
|
|||
"linkfix_not_found": "No link fix found for {0}.",
|
||||
"notify_cant_set": "This event doesn't support origin channel, Please specify a channel",
|
||||
"vote_reward": "Thank you for voting! You've received {0}.",
|
||||
"vote_suggest": "Voting for the bot once every 6 hours will get you {0}!",
|
||||
"vote_suggest": "Voting for the bot will get you {0}!",
|
||||
"vote_disabled": "Voting is disabled."
|
||||
}
|
Loading…
Add table
Reference in a new issue