mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 18:28:27 -04:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cb7743e244 | ||
|
7b5fbd184b | ||
|
a9cd1534c2 | ||
|
bca845d76a | ||
|
6c305860bc | ||
|
eee4e64d80 | ||
|
236a8aa9ac | ||
|
f491e3d37d | ||
|
1f11e4f227 | ||
|
5060d606cf | ||
|
23b3ad5837 | ||
|
7297318538 | ||
|
18619b4d3a | ||
|
ef06388335 | ||
|
d1db54498b | ||
|
eef5b3f948 | ||
|
d86b5b2b6c | ||
|
127a46a9b8 | ||
|
a7e1e8a982 |
93
CHANGELOG.md
93
CHANGELOG.md
@@ -1,7 +1,97 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||||
|
|
||||||
|
## [5.0.4] - 10.05.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.shopadd command` You can now sell commands in the shop. The command will execute as if you were the one running it when someone buys it
|
||||||
|
- type `.h .shopadd` for more info
|
||||||
|
- Added `.stickyroles` Users leaving the server will have their roles saved to the database and reapplied if they rejoin within 30 days.
|
||||||
|
- Giveaway commands
|
||||||
|
- `.ga start <duration> <text>` starts the giveway with the specified duration and message (prize). You may have up to 5 giveaways on the server at once
|
||||||
|
- `.ga end <id>` prematurely ends the giveaway and selects a winner
|
||||||
|
- `.ga cancel <id>` cancels the giveaway and doesn't select a winner
|
||||||
|
- `.ga list` lists active giveaways on the current server
|
||||||
|
- `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway has ended, or until the bot restarts.
|
||||||
|
- Users can join the giveaway by adding a :tada: reaction
|
||||||
|
- Added Todo Commands
|
||||||
|
- `.todo add <name>` - adds a new todo
|
||||||
|
- `.todo delete <id>` - deletes a todo item
|
||||||
|
- `.todo done <id>` - completes a todo (marks it with a checkmark)
|
||||||
|
- `.todo list` - lists all todos
|
||||||
|
- `.todo edit <id> <new message>` - edits a todo item message
|
||||||
|
- `.todo show <id>` - Shows the text of the specified todo item
|
||||||
|
- In addition to that, there are also Todo archive commands
|
||||||
|
- `.todo archive add <name>` - adds all current todos (completed and not completed) to the archived list, your current todo list will become cleared
|
||||||
|
- `.todo archive list` - lists all your archived todo lists
|
||||||
|
- `.todo archive show <id>` - shows the todo items from one of your archived lists
|
||||||
|
- `.todo archive delete <id>` - deletes and archived todo list
|
||||||
|
- Added `.queufairplay` / `.qfp` (music feature) re-added but it works differently
|
||||||
|
- Once you run it, it will reorganize currently queued songs so that they're in a fair order.
|
||||||
|
- Added `.clubrename` command to uh rename your club
|
||||||
|
- For self-hosters:
|
||||||
|
- Added `.sqlselectcsv` which will return results in a csv file instead of an embed.
|
||||||
|
- You can set whether nadeko ignores other bots in `bot.yml`
|
||||||
|
- You can set shop sale cut in `gambling.yml`
|
||||||
|
- Added a page parameter to `.feedlist`
|
||||||
|
- Added seconds/sec/s to `.convert` command
|
||||||
|
- Added `.prunecancel` to cancel an active prune
|
||||||
|
- Added progress reporting when using `.prune`.
|
||||||
|
- Added audit log reason for `.setrole` and some other features
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`)
|
||||||
|
- `.send` command should work consistently and correctly now. You can have targets from other shards too. The usage has been changed. refer to `.h .send` for more info
|
||||||
|
- `.serverinfo` no longer takes a server name. It only takes an id or no arguments
|
||||||
|
- You can now target a different channel with .repeat
|
||||||
|
- `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better
|
||||||
|
- The bot will now send a discord Reply to every command
|
||||||
|
- `.queuesearch` / `.qs` will now show the results with respective video thumbnails
|
||||||
|
- A lot of code cleanup (still a lot to be done) and Quality of Life improvements
|
||||||
|
- `.inrole` will now show mentions primarily, and use a spoiler to show usernames
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `.feed` should now correctly accept (and show) the message which can be passed as the third parameter
|
||||||
|
- `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the targeted channel
|
||||||
|
- Fixed `.invitelist` not paginating correctly
|
||||||
|
- `.serverinfo` will now correctly work for other shards
|
||||||
|
- `.send` will now correctly work for other shards
|
||||||
|
- `.translate` command will no longer fail if the user capitalizes the language name
|
||||||
|
- Fixed xp card user avatar not showing for some users
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- `.poll` commands removed as discord added polls
|
||||||
|
- `.scpl` and other music soundcloud commands have been removed as soundcloud isn't issuing new api tokens for years now
|
||||||
|
- Removed a lot of useless and nsfw commands
|
||||||
|
- Removed log voice presence TTS
|
||||||
|
- Cleanup: Removed a lot of obsolete aliases from aliases.yml
|
||||||
|
|
||||||
|
## [4.3.22] - 23.04.2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added `.setbanner` command (thx cata)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed pagination error due to a missing emoji
|
||||||
|
|
||||||
|
|
||||||
|
## [4.3.21] - 19.04.2023
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Possible fix for a duplicate in `.h bank`
|
||||||
|
- Fixed `.stock` command
|
||||||
|
- Fixed `.clubapply` and `.clubaccept`
|
||||||
|
- Removed some redundant discriminators
|
||||||
|
|
||||||
|
## [4.3.20] - 20.01.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed `.config searches followedStreams.maxCount` not working
|
||||||
|
|
||||||
## [4.3.19] - 20.01.2024
|
## [4.3.19] - 20.01.2024
|
||||||
|
|
||||||
@@ -36,7 +126,6 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- `.revimg` and `.revav` as google removed reverse image search
|
- `.revimg` and `.revav` as google removed reverse image search
|
||||||
-
|
|
||||||
|
|
||||||
## [4.3.17] - 06.09.2023
|
## [4.3.17] - 06.09.2023
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
w# Setting up NadekoBot on Linux
|
# Setting up NadekoBot on Linux
|
||||||
|
|
||||||
| Table of Contents |
|
| Table of Contents |
|
||||||
| :-------------------------------------------------- |
|
| :-------------------------------------------------- |
|
||||||
@@ -180,8 +180,8 @@ Choose:
|
|||||||
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
|
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
|
||||||
[2] to Run with Auto Updating on restart after using "die" command.
|
[2] to Run with Auto Updating on restart after using "die" command.
|
||||||
```
|
```
|
||||||
- Run `1` to update the bot upon restart. (This is done using the `.die` command)
|
- Run `1` to restart the bot without updating. (This is done using the `.die` command)
|
||||||
- Run `2` to restart the bot without updating. (This is also done using the `.die` command)
|
- Run `2` to update the bot upon restart. (This is also done using the `.die` command)
|
||||||
|
|
||||||
5. That's it! to detatch the tmux session:
|
5. That's it! to detatch the tmux session:
|
||||||
- Press `Ctrl` + `B`
|
- Press `Ctrl` + `B`
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Net.Core" Version="3.104.0" />
|
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
||||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -28,5 +28,10 @@ public class DiscordUser : DbEntity
|
|||||||
=> UserId.GetHashCode();
|
=> UserId.GetHashCode();
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
=> Username + "#" + Discriminator;
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Discriminator) || Discriminator == "0000")
|
||||||
|
return Username;
|
||||||
|
|
||||||
|
return Username + "#" + Discriminator;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -19,25 +19,25 @@ public class WaifuInfo : DbEntity
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var claimer = "no one";
|
|
||||||
var status = string.Empty;
|
var status = string.Empty;
|
||||||
|
|
||||||
var waifuUsername = Waifu.Username.TrimTo(20);
|
var waifuUsername = Waifu.ToString().TrimTo(20);
|
||||||
var claimerUsername = Claimer?.Username.TrimTo(20);
|
var claimer = Claimer?.ToString().TrimTo(20)
|
||||||
|
?? "no one";
|
||||||
|
|
||||||
|
var affinity = Affinity?.ToString().TrimTo(20);
|
||||||
|
|
||||||
if (ClaimerId is not null)
|
|
||||||
claimer = $"{claimerUsername}#{Claimer.Discriminator}";
|
|
||||||
if (AffinityId is null)
|
if (AffinityId is null)
|
||||||
status = $"... but {waifuUsername}'s heart is empty";
|
status = $"... but {waifuUsername}'s heart is empty";
|
||||||
else if (AffinityId == ClaimerId)
|
else if (AffinityId == ClaimerId)
|
||||||
status = $"... and {waifuUsername} likes {claimerUsername} too <3";
|
status = $"... and {waifuUsername} likes {claimer} too <3";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status =
|
status =
|
||||||
$"... but {waifuUsername}'s heart belongs to {Affinity.Username.TrimTo(20)}#{Affinity.Discriminator}";
|
$"... but {waifuUsername}'s heart belongs to {affinity}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"**{waifuUsername}#{Waifu.Discriminator}** - claimed by **{claimer}**\n\t{status}";
|
return $"**{waifuUsername}** - claimed by **{claimer}**\n\t{status}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -113,6 +113,7 @@ public sealed class DoAsUserMessage : IUserMessage
|
|||||||
|
|
||||||
public MessageFlags? Flags => _msg.Flags;
|
public MessageFlags? Flags => _msg.Flags;
|
||||||
|
|
||||||
|
[Obsolete("Obsolete in favor of InteractionMetadata")]
|
||||||
public IMessageInteraction Interaction => _msg.Interaction;
|
public IMessageInteraction Interaction => _msg.Interaction;
|
||||||
public MessageRoleSubscriptionData RoleSubscriptionData => _msg.RoleSubscriptionData;
|
public MessageRoleSubscriptionData RoleSubscriptionData => _msg.RoleSubscriptionData;
|
||||||
|
|
||||||
@@ -146,4 +147,7 @@ public sealed class DoAsUserMessage : IUserMessage
|
|||||||
public MessageResolvedData ResolvedData => _msg.ResolvedData;
|
public MessageResolvedData ResolvedData => _msg.ResolvedData;
|
||||||
|
|
||||||
public IUserMessage ReferencedMessage => _msg.ReferencedMessage;
|
public IUserMessage ReferencedMessage => _msg.ReferencedMessage;
|
||||||
|
|
||||||
|
public IMessageInteractionMetadata InteractionMetadata
|
||||||
|
=> _msg.InteractionMetadata;
|
||||||
}
|
}
|
@@ -502,6 +502,16 @@ public partial class Administration
|
|||||||
await ReplyConfirmLocalizedAsync(strs.set_avatar);
|
await ReplyConfirmLocalizedAsync(strs.set_avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[OwnerOnly]
|
||||||
|
public async Task SetBanner([Leftover] string img = null)
|
||||||
|
{
|
||||||
|
var success = await _service.SetBanner(img);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.set_banner);
|
||||||
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
[OwnerOnly]
|
[OwnerOnly]
|
||||||
public async Task SetGame(ActivityType type, [Leftover] string game = null)
|
public async Task SetGame(ActivityType type, [Leftover] string game = null)
|
||||||
|
@@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using NadekoBot.Common.ModuleBehaviors;
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using Nadeko.Common;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Services;
|
namespace NadekoBot.Modules.Administration.Services;
|
||||||
|
|
||||||
@@ -321,6 +320,40 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SetBanner(string img)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(img))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Uri.IsWellFormedUriString(img, UriKind.Absolute))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var uri = new Uri(img);
|
||||||
|
|
||||||
|
using var http = _httpFactory.CreateClient();
|
||||||
|
using var sr = await http.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);
|
||||||
|
|
||||||
|
if (!sr.IsImage())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sr.GetContentLength() > 8.Megabytes().Bytes)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
await using var imageStream = await sr.Content.ReadAsStreamAsync();
|
||||||
|
|
||||||
|
await _client.CurrentUser.ModifyAsync(x => x.Banner = new Image(imageStream));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ClearStartupCommands()
|
public void ClearStartupCommands()
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
|
@@ -363,7 +363,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
if (before.Username != after.Username)
|
if (before.Username != after.Username)
|
||||||
{
|
{
|
||||||
embed.WithTitle("👥 " + GetText(g, strs.username_changed))
|
embed.WithTitle("👥 " + GetText(g, strs.username_changed))
|
||||||
.WithDescription($"{before.Username}#{before.Discriminator} | {before.Id}")
|
.WithDescription($"{before.Username} | {before.Id}")
|
||||||
.AddField("Old Name", $"{before.Username}", true)
|
.AddField("Old Name", $"{before.Username}", true)
|
||||||
.AddField("New Name", $"{after.Username}", true)
|
.AddField("New Name", $"{after.Username}", true)
|
||||||
.WithFooter(CurrentTime(g))
|
.WithFooter(CurrentTime(g))
|
||||||
@@ -905,7 +905,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
str = "🎙"
|
str = "🎙"
|
||||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||||
+ GetText(logChannel.Guild,
|
+ GetText(logChannel.Guild,
|
||||||
strs.user_vmoved("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
strs.user_vmoved("👤" + Format.Bold(usr.Username),
|
||||||
Format.Bold(beforeVch?.Name ?? ""),
|
Format.Bold(beforeVch?.Name ?? ""),
|
||||||
Format.Bold(afterVch?.Name ?? "")));
|
Format.Bold(afterVch?.Name ?? "")));
|
||||||
}
|
}
|
||||||
@@ -914,7 +914,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
str = "🎙"
|
str = "🎙"
|
||||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||||
+ GetText(logChannel.Guild,
|
+ GetText(logChannel.Guild,
|
||||||
strs.user_vjoined("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
strs.user_vjoined("👤" + Format.Bold(usr.Username),
|
||||||
Format.Bold(afterVch?.Name ?? "")));
|
Format.Bold(afterVch?.Name ?? "")));
|
||||||
}
|
}
|
||||||
else if (afterVch is null)
|
else if (afterVch is null)
|
||||||
@@ -922,7 +922,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
str = "🎙"
|
str = "🎙"
|
||||||
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
+ Format.Code(PrettyCurrentTime(usr.Guild))
|
||||||
+ GetText(logChannel.Guild,
|
+ GetText(logChannel.Guild,
|
||||||
strs.user_vleft("👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
strs.user_vleft("👤" + Format.Bold(usr.Username),
|
||||||
Format.Bold(beforeVch.Name ?? "")));
|
Format.Bold(beforeVch.Name ?? "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -239,7 +239,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
|
|
||||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||||
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
||||||
$"**{usr.Username}#{usr.Discriminator}**",
|
$"**{usr.Username}**",
|
||||||
footer: $"ID: {usr.Id}");
|
footer: $"ID: {usr.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
|
|
||||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||||
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user),
|
||||||
$"**{usr.Username}#{usr.Discriminator}**",
|
$"**{usr.Username}**",
|
||||||
footer: $"ID: {usr.Id}");
|
footer: $"ID: {usr.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -292,7 +292,7 @@ public partial class Help : NadekoModule<HelpService>
|
|||||||
.WithTitle(GetText(strs.cmd_group_commands(group.Name)))
|
.WithTitle(GetText(strs.cmd_group_commands(group.Name)))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
foreach (var cmd in group.Commands)
|
foreach (var cmd in group.Commands.DistinctBy(x => x.Aliases[0]))
|
||||||
{
|
{
|
||||||
eb.AddField(prefix + cmd.Aliases.First(), cmd.RealSummary(_strings, _medusae, Culture, prefix));
|
eb.AddField(prefix + cmd.Aliases.First(), cmd.RealSummary(_strings, _medusae, Culture, prefix));
|
||||||
}
|
}
|
||||||
|
@@ -85,11 +85,11 @@ public partial class Searches
|
|||||||
.WithUrl($"https://www.tradingview.com/chart/?symbol={stock.Symbol}")
|
.WithUrl($"https://www.tradingview.com/chart/?symbol={stock.Symbol}")
|
||||||
.WithTitle(stock.Name)
|
.WithTitle(stock.Name)
|
||||||
.AddField(GetText(strs.price), $"{sign} **{price}**", true)
|
.AddField(GetText(strs.price), $"{sign} **{price}**", true)
|
||||||
.AddField(GetText(strs.market_cap), stock.MarketCap.ToString("C0", localCulture), true)
|
.AddField(GetText(strs.market_cap), stock.MarketCap, true)
|
||||||
.AddField(GetText(strs.volume_24h), stock.DailyVolume.ToString("C0", localCulture), true)
|
.AddField(GetText(strs.volume_24h), stock.DailyVolume.ToString("C0", localCulture), true)
|
||||||
.AddField("Change", $"{change} ({changePercent})", true)
|
.AddField("Change", $"{change} ({changePercent})", true)
|
||||||
.AddField("Change 50d", $"{sign50}{change50}", true)
|
// .AddField("Change 50d", $"{sign50}{change50}", true)
|
||||||
.AddField("Change 200d", $"{sign200}{change200}", true)
|
// .AddField("Change 200d", $"{sign200}{change200}", true)
|
||||||
.WithFooter(stock.Exchange);
|
.WithFooter(stock.Exchange);
|
||||||
|
|
||||||
var message = await ctx.Channel.EmbedAsync(eb);
|
var message = await ctx.Channel.EmbedAsync(eb);
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
using CsvHelper;
|
using AngleSharp;
|
||||||
|
using AngleSharp.Html.Dom;
|
||||||
|
using CsvHelper;
|
||||||
using CsvHelper.Configuration;
|
using CsvHelper.Configuration;
|
||||||
|
using CsvHelper.Configuration.Attributes;
|
||||||
using Google.Protobuf.WellKnownTypes;
|
using Google.Protobuf.WellKnownTypes;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
@@ -23,33 +26,61 @@ public sealed class DefaultStockDataService : IStockDataService, INService
|
|||||||
return default;
|
return default;
|
||||||
|
|
||||||
using var http = _httpClientFactory.CreateClient();
|
using var http = _httpClientFactory.CreateClient();
|
||||||
var data = await http.GetFromJsonAsync<YahooQueryModel>(
|
|
||||||
$"https://query1.finance.yahoo.com/v7/finance/quote?symbols={query}");
|
|
||||||
|
|
||||||
if (data is null)
|
|
||||||
return default;
|
|
||||||
|
|
||||||
var symbol = data.QuoteResponse.Result.FirstOrDefault();
|
|
||||||
|
|
||||||
if (symbol is null)
|
var quoteHtmlPage = $"https://finance.yahoo.com/quote/{query.ToUpperInvariant()}";
|
||||||
return default;
|
|
||||||
|
var config = Configuration.Default.WithDefaultLoader();
|
||||||
|
using var document = await BrowsingContext.New(config).OpenAsync(quoteHtmlPage);
|
||||||
|
var divElem =
|
||||||
|
document.QuerySelector(
|
||||||
|
"#quote-header-info > div:nth-child(2) > div > div > h1");
|
||||||
|
var tickerName = (divElem)?.TextContent;
|
||||||
|
|
||||||
|
var marketcap = document
|
||||||
|
.QuerySelectorAll("table")
|
||||||
|
.Skip(1)
|
||||||
|
.First()
|
||||||
|
.QuerySelector("tbody > tr > td:nth-child(2)")
|
||||||
|
?.TextContent;
|
||||||
|
|
||||||
|
|
||||||
|
var volume = document.QuerySelector("td[data-test='AVERAGE_VOLUME_3MONTH-value']")
|
||||||
|
?.TextContent;
|
||||||
|
|
||||||
|
var close= document.QuerySelector("td[data-test='PREV_CLOSE-value']")
|
||||||
|
?.TextContent ?? "0";
|
||||||
|
|
||||||
|
var price = document
|
||||||
|
.QuerySelector("#quote-header-info")
|
||||||
|
?.QuerySelector("fin-streamer[data-field='regularMarketPrice']")
|
||||||
|
?.TextContent ?? close;
|
||||||
|
|
||||||
|
// var data = await http.GetFromJsonAsync<YahooQueryModel>(
|
||||||
|
// $"https://query1.finance.yahoo.com/v7/finance/quote?symbols={query}");
|
||||||
|
//
|
||||||
|
// if (data is null)
|
||||||
|
// return default;
|
||||||
|
|
||||||
|
// var symbol = data.QuoteResponse.Result.FirstOrDefault();
|
||||||
|
|
||||||
|
// if (symbol is null)
|
||||||
|
// return default;
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
Name = symbol.LongName,
|
Name = tickerName,
|
||||||
Symbol = symbol.Symbol,
|
Symbol = query,
|
||||||
Price = symbol.RegularMarketPrice,
|
Price = double.Parse(price, NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||||
Close = symbol.RegularMarketPreviousClose,
|
Close = double.Parse(close, NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||||
MarketCap = symbol.MarketCap,
|
MarketCap = marketcap,
|
||||||
Change50d = symbol.FiftyDayAverageChangePercent,
|
DailyVolume = (long)double.Parse(volume ?? "0", NumberStyles.Any, CultureInfo.InvariantCulture),
|
||||||
Change200d = symbol.TwoHundredDayAverageChangePercent,
|
|
||||||
DailyVolume = symbol.AverageDailyVolume10Day,
|
|
||||||
Exchange = symbol.FullExchangeName
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// Log.Warning(ex, "Error getting stock data: {ErrorMessage}", ex.Message);
|
Log.Warning(ex, "Error getting stock data: {ErrorMessage}", ex.ToString());
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ public class StockData
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Symbol { get; set; }
|
public string Symbol { get; set; }
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public long MarketCap { get; set; }
|
public string MarketCap { get; set; }
|
||||||
public double Close { get; set; }
|
public double Close { get; set; }
|
||||||
public double Change50d { get; set; }
|
public double Change50d { get; set; }
|
||||||
public double Change200d { get; set; }
|
public double Change200d { get; set; }
|
||||||
|
@@ -30,7 +30,7 @@ public class SearchesConfigService : ConfigServiceBase<SearchesConfig>
|
|||||||
|
|
||||||
AddParsedProp("followedStreams.maxCount",
|
AddParsedProp("followedStreams.maxCount",
|
||||||
sc => sc.FollowedStreams.MaxCount,
|
sc => sc.FollowedStreams.MaxCount,
|
||||||
ConfigParsers.InsensitiveEnum,
|
int.TryParse,
|
||||||
ConfigPrinters.ToString);
|
ConfigPrinters.ToString);
|
||||||
|
|
||||||
Migrate();
|
Migrate();
|
||||||
|
@@ -259,8 +259,8 @@ public partial class Xp
|
|||||||
await ReplyConfirmLocalizedAsync(strs.club_applied(Format.Bold(club.ToString())));
|
await ReplyConfirmLocalizedAsync(strs.club_applied(Format.Bold(club.ToString())));
|
||||||
else if (result == ClubApplyResult.Banned)
|
else if (result == ClubApplyResult.Banned)
|
||||||
await ReplyErrorLocalizedAsync(strs.club_join_banned);
|
await ReplyErrorLocalizedAsync(strs.club_join_banned);
|
||||||
else if (result == ClubApplyResult.InsufficientLevel)
|
else if (result == ClubApplyResult.AlreadyApplied)
|
||||||
await ReplyErrorLocalizedAsync(strs.club_insuff_lvl);
|
await ReplyErrorLocalizedAsync(strs.club_already_applied);
|
||||||
else if (result == ClubApplyResult.AlreadyInAClub)
|
else if (result == ClubApplyResult.AlreadyInAClub)
|
||||||
await ReplyErrorLocalizedAsync(strs.club_already_in);
|
await ReplyErrorLocalizedAsync(strs.club_already_in);
|
||||||
}
|
}
|
||||||
|
@@ -146,7 +146,7 @@ public class ClubService : INService, IClubService
|
|||||||
return ClubApplyResult.Banned;
|
return ClubApplyResult.Banned;
|
||||||
|
|
||||||
if (club.Applicants.Any(x => x.UserId == du.Id))
|
if (club.Applicants.Any(x => x.UserId == du.Id))
|
||||||
return ClubApplyResult.InsufficientLevel;
|
return ClubApplyResult.AlreadyApplied;
|
||||||
|
|
||||||
var app = new ClubApplicants
|
var app = new ClubApplicants
|
||||||
{
|
{
|
||||||
|
@@ -27,8 +27,7 @@ public interface IClubService
|
|||||||
public enum ClubApplyResult
|
public enum ClubApplyResult
|
||||||
{
|
{
|
||||||
Success,
|
Success,
|
||||||
|
|
||||||
AlreadyInAClub,
|
AlreadyInAClub,
|
||||||
Banned,
|
Banned,
|
||||||
InsufficientLevel
|
AlreadyApplied
|
||||||
}
|
}
|
@@ -27,7 +27,7 @@
|
|||||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
|
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageReference Include="CsvHelper" Version="28.0.1" />
|
<PackageReference Include="CsvHelper" Version="28.0.1" />
|
||||||
<PackageReference Include="Discord.Net" Version="3.203.0" />
|
<PackageReference Include="Discord.Net" Version="3.204.0" />
|
||||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
||||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.62.1.3205" />
|
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.62.1.3205" />
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
|
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
|
||||||
<PackageReference Include="SharpToken" Version="1.2.14" />
|
<PackageReference Include="SharpToken" Version="1.2.14" />
|
||||||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17" />
|
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta17" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.8" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
|
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
|
||||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" />
|
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
|
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
|
||||||
|
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
|
|||||||
|
|
||||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||||
{
|
{
|
||||||
public const string BOT_VERSION = "4.3.19";
|
public const string BOT_VERSION = "4.3.22";
|
||||||
|
|
||||||
public string Author
|
public string Author
|
||||||
=> "Kwoth#2452";
|
=> "Kwoth#2452";
|
||||||
|
@@ -167,8 +167,8 @@ public static class MessageChannelExtensions
|
|||||||
private const string BUTTON_LEFT = "BUTTON_LEFT";
|
private const string BUTTON_LEFT = "BUTTON_LEFT";
|
||||||
private const string BUTTON_RIGHT = "BUTTON_RIGHT";
|
private const string BUTTON_RIGHT = "BUTTON_RIGHT";
|
||||||
|
|
||||||
private static readonly IEmote _arrowLeft = Emote.Parse("<:x:969658061805465651>");
|
private static readonly IEmote _arrowLeft = Emote.Parse("<:x:1232256519844790302>");
|
||||||
private static readonly IEmote _arrowRight = Emote.Parse("<:x:969658062220701746>");
|
private static readonly IEmote _arrowRight = Emote.Parse("<:x:1232256515298295838>");
|
||||||
|
|
||||||
public static Task SendPaginatedConfirmAsync(
|
public static Task SendPaginatedConfirmAsync(
|
||||||
this ICommandContext ctx,
|
this ICommandContext ctx,
|
||||||
|
@@ -195,6 +195,8 @@ setnick:
|
|||||||
setavatar:
|
setavatar:
|
||||||
- setavatar
|
- setavatar
|
||||||
- setav
|
- setav
|
||||||
|
setbanner:
|
||||||
|
- setbanner
|
||||||
setgame:
|
setgame:
|
||||||
- setgame
|
- setgame
|
||||||
send:
|
send:
|
||||||
|
@@ -402,6 +402,10 @@ setavatar:
|
|||||||
desc: "Sets a new avatar image for the NadekoBot. Parameter is a direct link to an image."
|
desc: "Sets a new avatar image for the NadekoBot. Parameter is a direct link to an image."
|
||||||
args:
|
args:
|
||||||
- "https://i.imgur.com/xTG3a1I.jpg"
|
- "https://i.imgur.com/xTG3a1I.jpg"
|
||||||
|
setbanner:
|
||||||
|
desc: "Sets a new banner image for the NadekoBot. Parameter is a direct link to an image. Supports gifs."
|
||||||
|
args:
|
||||||
|
- "https://i.imgur.com/xTG3a1I.jpg"
|
||||||
setgame:
|
setgame:
|
||||||
desc: "Sets the bots game status to either Playing, Listening, or Watching."
|
desc: "Sets the bots game status to either Playing, Listening, or Watching."
|
||||||
args:
|
args:
|
||||||
|
@@ -184,6 +184,7 @@
|
|||||||
"setrole": "Successfully added role {0} to user {1}",
|
"setrole": "Successfully added role {0} to user {1}",
|
||||||
"setrole_err": "Failed to add role. I have insufficient permissions.",
|
"setrole_err": "Failed to add role. I have insufficient permissions.",
|
||||||
"set_avatar": "New avatar set!",
|
"set_avatar": "New avatar set!",
|
||||||
|
"set_banner": "New banner set!",
|
||||||
"set_channel_name": "New channel name set.",
|
"set_channel_name": "New channel name set.",
|
||||||
"set_game": "New game set!",
|
"set_game": "New game set!",
|
||||||
"set_stream": "New stream set!",
|
"set_stream": "New stream set!",
|
||||||
@@ -838,7 +839,7 @@
|
|||||||
"server_leaderboard": "Server XP Leaderboard",
|
"server_leaderboard": "Server XP Leaderboard",
|
||||||
"global_leaderboard": "Global XP Leaderboard",
|
"global_leaderboard": "Global XP Leaderboard",
|
||||||
"modified": "Modified server XP of the user {0} by {1}",
|
"modified": "Modified server XP of the user {0} by {1}",
|
||||||
"club_insuff_lvl": "You're insufficient level to join that club.",
|
"club_already_applied": "You've already applied to that club.",
|
||||||
"club_join_banned": "You're banned from that club.",
|
"club_join_banned": "You're banned from that club.",
|
||||||
"club_already_in": "You are already a member of a club.",
|
"club_already_in": "You are already a member of a club.",
|
||||||
"club_create_error_name": "Failed creating the club. A club with that name already exists.",
|
"club_create_error_name": "Failed creating the club. A club with that name already exists.",
|
||||||
|
Reference in New Issue
Block a user