Compare commits
2 commits
9fe75d930f
...
97fe14cf5a
Author | SHA1 | Date | |
---|---|---|---|
97fe14cf5a | |||
b1d28296f0 |
11 changed files with 162 additions and 72 deletions
src
EllieBot.VotesApi
EllieBot
Modules
data
strings
|
@ -25,8 +25,7 @@ namespace EllieBot.VotesApi
|
||||||
|
|
||||||
services.AddGrpcClient<VoteService.VoteServiceClient>(options =>
|
services.AddGrpcClient<VoteService.VoteServiceClient>(options =>
|
||||||
{
|
{
|
||||||
var grpcServiceUrl = Configuration["GrpcServiceUrl"]!;
|
options.Address = new Uri("http://127.0.0.1:59384");
|
||||||
options.Address = new Uri(grpcServiceUrl);
|
|
||||||
})
|
})
|
||||||
.ConfigureChannel((sp, c) =>
|
.ConfigureChannel((sp, c) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,15 +167,49 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||||
|
|
||||||
var (amount, msg) = await _service.GetAmountAndMessage(ctx.User.Id, reward);
|
var (amount, msg) = await _service.GetAmountAndMessage(ctx.User.Id, reward);
|
||||||
|
|
||||||
var prepend = GetText(strs.vote_suggest(N(amount)));
|
var prepend = GetText(strs.vote_suggest(Format.Bold(N(amount))));
|
||||||
msg = prepend + "\n\n" + msg;
|
msg = prepend + "\n\n" + msg;
|
||||||
|
|
||||||
var inter = CreateRemindMeInteraction(6);
|
var inter = CreateRemindMeInteraction(6) as EllieButtonInteractionHandler;
|
||||||
|
var eb = CreateEmbed()
|
||||||
|
.WithOkColor()
|
||||||
|
.WithDescription(msg);
|
||||||
|
|
||||||
await Response()
|
var cb = new ComponentBuilder();
|
||||||
.Confirm(msg)
|
|
||||||
.Interaction(inter)
|
// Add vote platform buttons if any are configured
|
||||||
.SendAsync();
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
@ -215,10 +249,10 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||||
var toSend = Response()
|
var toSend = Response()
|
||||||
.File(stream, "timely.png");
|
.File(stream, "timely.png");
|
||||||
|
|
||||||
#if GLOBAL_NADEKO
|
#if GLOBAL_ELLIE
|
||||||
if (_rng.Next(0, 8) == 0)
|
if (_rng.Next(0, 8) == 0)
|
||||||
toSend = toSend
|
toSend = toSend
|
||||||
.Text("*[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha.*");
|
.Text("*[Sub on Patreon](https://patreon.com/elliebot) to remove captcha.*");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var captchaMessage = await toSend.SendAsync();
|
var captchaMessage = await toSend.SendAsync();
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace EllieBot.Modules.Gambling.Common;
|
||||||
public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||||
{
|
{
|
||||||
[Comment("""DO NOT CHANGE""")]
|
[Comment("""DO NOT CHANGE""")]
|
||||||
public int Version { get; set; } = 12;
|
public int Version { get; set; } = 13;
|
||||||
|
|
||||||
[Comment("""Currency settings""")]
|
[Comment("""Currency settings""")]
|
||||||
public CurrencyConfig Currency { get; set; }
|
public CurrencyConfig Currency { get; set; }
|
||||||
|
@ -68,6 +68,15 @@ public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||||
Id of the channel to send a message to after a user votes
|
Id of the channel to send a message to after a user votes
|
||||||
""")]
|
""")]
|
||||||
public ulong? VoteFeedChannelId { get; set; }
|
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""")]
|
[Comment("""Slot config""")]
|
||||||
public SlotsConfig Slots { get; set; }
|
public SlotsConfig Slots { get; set; }
|
||||||
|
|
|
@ -12,12 +12,6 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
||||||
public override string Name
|
public override string Name
|
||||||
=> "gambling";
|
=> "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)
|
public GamblingConfigService(IConfigSeria serializer, IPubSub pubSub)
|
||||||
: base(FILE_PATH, serializer, pubSub, _changeKey)
|
: base(FILE_PATH, serializer, pubSub, _changeKey)
|
||||||
{
|
{
|
||||||
|
@ -154,51 +148,12 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
||||||
|
|
||||||
public void Migrate()
|
public void Migrate()
|
||||||
{
|
{
|
||||||
if (data.Version < 2)
|
if (data.Version < 13)
|
||||||
{
|
{
|
||||||
ModifyConfig(c =>
|
ModifyConfig(c =>
|
||||||
{
|
{
|
||||||
c.Waifu.Items = c.Waifu.Items.Concat(_antiGiftSeed).ToList();
|
c.Version = 13;
|
||||||
c.Version = 2;
|
c.VotePlatforms = [];
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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("nadeko:economy");
|
private static readonly TypedKey<EconomyResult> _ecoKey = new("ellie:economy");
|
||||||
|
|
||||||
private static readonly SemaphoreSlim _timelyLock = new(1, 1);
|
private static readonly SemaphoreSlim _timelyLock = new(1, 1);
|
||||||
|
|
||||||
|
@ -235,22 +235,22 @@ public class GamblingService : IEService, IReadyExecutor
|
||||||
|
|
||||||
originalAmount += (int)(originalAmount * percentBonus);
|
originalAmount += (int)(originalAmount * percentBonus);
|
||||||
|
|
||||||
var msg = $"{N(originalAmount)} base reward.\n";
|
var msg = $"**{N(originalAmount)}** base reward\n\n";
|
||||||
if (boostGuilds.Count > 0)
|
if (boostGuilds.Count > 0)
|
||||||
{
|
{
|
||||||
if (booster)
|
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
|
else
|
||||||
msg += $"❌ +0 bonus for boosting {userInfo.guild}.\n";
|
msg += $"\\❌ *+0 bonus for boosting {userInfo.guild}*\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ps.GetConfig().IsEnabled)
|
if (_ps.GetConfig().IsEnabled)
|
||||||
{
|
{
|
||||||
if (percentBonus > float.Epsilon)
|
if (percentBonus > float.Epsilon)
|
||||||
msg +=
|
msg +=
|
||||||
$"✅ *+{percentBonus:P0} bonus for the [Patreon](https://patreon.com/nadekobot) pledge! <:hart:746995901758832712>*";
|
$"\\✅ *+{percentBonus:P0} bonus for the [Patreon](https://patreon.com/elliebot) pledge! <:hart:746995901758832712>*\n";
|
||||||
else
|
else
|
||||||
msg += $"❌ +0 bonus for the [Patreon](https://patreon.com/nadekobot) pledge.";
|
msg += $"\\❌ *+0 bonus for the [Patreon](https://patreon.com/elliebot) pledge*\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (originalAmount, msg);
|
return (originalAmount, msg);
|
||||||
|
|
|
@ -11,4 +11,42 @@ public class Owner(VoteRewardService vrs) : EllieModule
|
||||||
vrs.SetVoiceChannel(ctx.Channel);
|
vrs.SetVoiceChannel(ctx.Channel);
|
||||||
await ctx.OkAsync();
|
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",
|
"Module": "Administration",
|
||||||
"Options": null,
|
"Options": null,
|
||||||
"Requirements": [
|
"Requirements": [
|
||||||
"Administrator Server Permission"
|
"ManageRoles Server Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -991,7 +991,7 @@
|
||||||
"Module": "Administration",
|
"Module": "Administration",
|
||||||
"Options": null,
|
"Options": null,
|
||||||
"Requirements": [
|
"Requirements": [
|
||||||
"Administrator Server Permission"
|
"ManageRoles Server Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1007,7 +1007,7 @@
|
||||||
"Module": "Administration",
|
"Module": "Administration",
|
||||||
"Options": null,
|
"Options": null,
|
||||||
"Requirements": [
|
"Requirements": [
|
||||||
"Administrator Server Permission"
|
"ManageRoles Server Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1025,7 +1025,7 @@
|
||||||
"Module": "Administration",
|
"Module": "Administration",
|
||||||
"Options": null,
|
"Options": null,
|
||||||
"Requirements": [
|
"Requirements": [
|
||||||
"Administrator Server Permission"
|
"ManageRoles Server Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2990,6 +2990,19 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Gambling": [
|
"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": [
|
"Aliases": [
|
||||||
".timely"
|
".timely"
|
||||||
|
@ -5211,6 +5224,22 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"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": [
|
"Permissions": [
|
||||||
{
|
{
|
||||||
"Aliases": [
|
"Aliases": [
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# DO NOT CHANGE
|
# DO NOT CHANGE
|
||||||
version: 12
|
version: 13
|
||||||
# Currency settings
|
# Currency settings
|
||||||
currency:
|
currency:
|
||||||
# What is the emoji/character which represents the currency
|
# What is the emoji/character which represents the currency
|
||||||
|
@ -270,6 +270,14 @@ patreonCurrencyPerCent: 1
|
||||||
# Currency reward per vote.
|
# Currency reward per vote.
|
||||||
# This will work only if you've set up VotesApi and correct credentials for topgg and/or discords voting
|
# This will work only if you've set up VotesApi and correct credentials for topgg and/or discords voting
|
||||||
voteReward: 100
|
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
|
# Slot config
|
||||||
slots:
|
slots:
|
||||||
# Hex value of the color which the numbers on the slot image will have.
|
# Hex value of the color which the numbers on the slot image will have.
|
||||||
|
|
|
@ -1656,4 +1656,6 @@ linkfixlist:
|
||||||
votefeed:
|
votefeed:
|
||||||
- votefeed
|
- votefeed
|
||||||
vote:
|
vote:
|
||||||
- vote
|
- vote
|
||||||
|
massping:
|
||||||
|
- massping
|
|
@ -5190,5 +5190,21 @@ votefeed:
|
||||||
ex:
|
ex:
|
||||||
- '#votefeed'
|
- '#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:
|
params:
|
||||||
- { }
|
- { }
|
|
@ -1243,6 +1243,6 @@
|
||||||
"linkfix_not_found": "No link fix found for {0}.",
|
"linkfix_not_found": "No link fix found for {0}.",
|
||||||
"notify_cant_set": "This event doesn't support origin channel, Please specify a channel",
|
"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_reward": "Thank you for voting! You've received {0}.",
|
||||||
"vote_suggest": "Voting for the bot will get you {0}!",
|
"vote_suggest": "Voting for the bot once every 6 hours will get you {0}!",
|
||||||
"vote_disabled": "Voting is disabled."
|
"vote_disabled": "Voting is disabled."
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue