mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
93df4f3bf3 | ||
|
073b832065 | ||
|
a01e580e03 | ||
|
6124e2fab5 | ||
|
4dd31d6a0b | ||
|
e8706d4006 | ||
|
140cc43c98 | ||
|
26b7149435 | ||
|
b354ee7269 | ||
|
b829ca0109 | ||
|
37acdb81e8 | ||
|
a9aea65134 | ||
|
5c03c5ba16 | ||
|
42f00c08fa | ||
|
598d3b8967 | ||
|
8df41c749b | ||
|
0eaa8be2d2 | ||
|
bdbe76f9f8 | ||
|
08b609a4b4 | ||
|
42d13b32b2 | ||
|
096ada367f | ||
|
0fed33ebda | ||
|
cb9e918681 | ||
|
bbf167df4d | ||
|
595a2b401c | ||
|
5713e8414e | ||
|
a551caf0da | ||
|
b13f05c4c0 | ||
|
6d6a3a811f | ||
|
fb4aac9f0d | ||
|
a98981de86 | ||
|
9ef3646711 | ||
|
9c174b8b6f | ||
|
657c1e461c | ||
|
f5a4a698bd | ||
|
8112337aaf | ||
|
73f7394e31 |
41
CHANGELOG.md
41
CHANGELOG.md
@@ -2,13 +2,40 @@
|
|||||||
|
|
||||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||||
|
|
||||||
## [4.3.12] - 11.02.2023
|
## [4.3.15] - 21.05.2023
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed -w 0 in trivia
|
||||||
|
- Fixed `.rps` amount field in the response
|
||||||
|
- Fixed `.showembed` output
|
||||||
|
- Fixed bank award's incorrect output message
|
||||||
|
|
||||||
|
## [4.3.14] - 02.04.2023
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed voice hearbeat issue
|
||||||
|
- `.banktake` had ok/error responses flipped. No functional change
|
||||||
|
- PermRole should deny messages in threads todo
|
||||||
|
- Fixed chucknorris jokes
|
||||||
|
- `.logserver` will now
|
||||||
|
|
||||||
|
## [4.3.13] - 20.02.2023
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.log userpresence`
|
||||||
|
- `.q` will now use `yt-dlp` if anything other than `ytProvider: Ytdl` is set in `data/searches.yml`
|
||||||
|
- Fixed Title links on some embeds
|
||||||
|
|
||||||
|
## [4.3.12] - 12.02.2023
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed `.betstats` not working on european locales
|
- Fixed `.betstats` not working on european locales
|
||||||
- Timed `.ban` will work on users who are not in the server
|
- Timed `.ban` will work on users who are not in the server
|
||||||
- Fixed some bugs in the medusa system
|
- Fixed some bugs in the medusa system
|
||||||
|
|
||||||
## [4.3.11] - 21.01.2023
|
## [4.3.11] - 21.01.2023
|
||||||
|
|
||||||
@@ -44,7 +71,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
|
|
||||||
## [4.3.10] - 10.11.2022
|
## [4.3.10] - 10.11.2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `.filterlist` / `.fl` command which lists link and invite filtering channels and status
|
- `.filterlist` / `.fl` command which lists link and invite filtering channels and status
|
||||||
- Added support for `%target%` placeholder in `.alias` command
|
- Added support for `%target%` placeholder in `.alias` command
|
||||||
@@ -53,13 +80,13 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or data/medusae/medusa.yml may need to be edited manually
|
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or data/medusae/medusa.yml may need to be edited manually
|
||||||
- Several club related command have their error messages improved
|
- Several club related command have their error messages improved
|
||||||
- Updated help text for .antispam and .antiraid
|
- Updated help text for .antispam and .antiraid
|
||||||
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the format `HH:mm dd.MM.YYYY`
|
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the format `HH:mm dd.MM.YYYY`
|
||||||
- OwnerId will be automatically added to `creds.yml` at bot startup if it's missing
|
- OwnerId will be automatically added to `creds.yml` at bot startup if it's missing
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed `.cmdcd` console error
|
- Fixed `.cmdcd` console error
|
||||||
- Fixed an error when currency is add per xp
|
- Fixed an error when currency is add per xp
|
||||||
@@ -71,7 +98,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
|
|
||||||
## [4.3.9] - 12.10.2022
|
## [4.3.9] - 12.10.2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `.betstats` shows sum of all bets, payouts and the payout rate in %. Updates once an hour
|
- `.betstats` shows sum of all bets, payouts and the payout rate in %. Updates once an hour
|
||||||
|
|
||||||
|
@@ -24,6 +24,10 @@ The list below is not complete. Use commands above to see up-to-date list for yo
|
|||||||
|
|
||||||
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
|
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
|
||||||
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
|
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
|
||||||
|
`hangman.currency_reward` - Sets the amount of currency a user will win if they win a game of hangman.
|
||||||
|
`chatbot` - Sets which chatbot API the bot should use, values: `gpt3`, `cleverbot`.
|
||||||
|
`gpt.model` - Sets which GPT-3 model the bot should use, values: `ada001`, `babbage001`, `curie001`, `davinci003`.
|
||||||
|
`gpt.max_tokens` - Sets the limit of tokens GPT-3 can use per call. Find out more about tokens [here](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them).
|
||||||
|
|
||||||
*more settings may be available in `data/games.yml` file*
|
*more settings may be available in `data/games.yml` file*
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ It is recommended that you use **Ubuntu 20.04**, as there have been nearly no pr
|
|||||||
|
|
||||||
##### Compatible operating systems:
|
##### Compatible operating systems:
|
||||||
|
|
||||||
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10
|
- Ubuntu: 16.04, 18.04, 20.04
|
||||||
- Mint: 19, 20
|
- Mint: 19, 20
|
||||||
- Debian: 10, 11
|
- Debian: 10, 11
|
||||||
- CentOS: 7
|
- CentOS: 7
|
||||||
|
@@ -123,7 +123,7 @@ In order to use music commands, you need ffmpeg and youtube-dl installed.
|
|||||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
||||||
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
|
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
|
||||||
|
|
||||||
[Updater]: https://dl.nadeko.bot/
|
[Updater]: https://dl.nadeko.bot/v3/
|
||||||
[Notepad++]: https://notepad-plus-plus.org/
|
[Notepad++]: https://notepad-plus-plus.org/
|
||||||
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
||||||
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
||||||
|
@@ -89,6 +89,5 @@ Some features have their own specific placeholders which are noted in that featu
|
|||||||
|
|
||||||
- `%rngX-Y%` - Returns a random number between X and Y
|
- `%rngX-Y%` - Returns a random number between X and Y
|
||||||
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
||||||
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on Expressions)
|
|
||||||
|
|
||||||

|

|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#nullable disable warnings
|
#nullable disable warnings
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace NadekoBot;
|
namespace NadekoBot;
|
||||||
|
|
||||||
@@ -7,14 +8,14 @@ public sealed record SmartEmbedArrayElementText : SmartEmbedTextBase
|
|||||||
{
|
{
|
||||||
public string Color { get; init; } = string.Empty;
|
public string Color { get; init; } = string.Empty;
|
||||||
|
|
||||||
public SmartEmbedArrayElementText() : base()
|
public SmartEmbedArrayElementText()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmartEmbedArrayElementText(IEmbed eb) : base(eb)
|
public SmartEmbedArrayElementText(IEmbed eb) : base(eb)
|
||||||
{
|
{
|
||||||
|
Color = eb.Color is { } c ? new Rgba32(c.R, c.G, c.B).ToHex() : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override EmbedBuilder GetEmbedInternal()
|
protected override EmbedBuilder GetEmbedInternal()
|
||||||
@@ -63,6 +64,7 @@ public abstract record SmartEmbedTextBase : SmartText
|
|||||||
public SmartTextEmbedFooter Footer { get; init; }
|
public SmartTextEmbedFooter Footer { get; init; }
|
||||||
public SmartTextEmbedField[] Fields { get; init; }
|
public SmartTextEmbedField[] Fields { get; init; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsValid
|
public bool IsValid
|
||||||
=> !string.IsNullOrWhiteSpace(Title)
|
=> !string.IsNullOrWhiteSpace(Title)
|
||||||
|| !string.IsNullOrWhiteSpace(Description)
|
|| !string.IsNullOrWhiteSpace(Description)
|
||||||
@@ -100,7 +102,7 @@ public abstract record SmartEmbedTextBase : SmartText
|
|||||||
IconUrl = ef.IconUrl
|
IconUrl = ef.IconUrl
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (eb.Fields.Length > 0)
|
if (eb.Fields.Length > 0)
|
||||||
{
|
{
|
||||||
Fields = eb.Fields.Select(field
|
Fields = eb.Fields.Select(field
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace NadekoBot;
|
namespace NadekoBot;
|
||||||
|
|
||||||
public sealed record SmartEmbedTextArray : SmartText
|
public sealed record SmartEmbedTextArray : SmartText
|
||||||
@@ -6,6 +8,7 @@ public sealed record SmartEmbedTextArray : SmartText
|
|||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
public SmartEmbedArrayElementText[] Embeds { get; set; }
|
public SmartEmbedArrayElementText[] Embeds { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsValid
|
public bool IsValid
|
||||||
=> Embeds?.All(x => x.IsValid) ?? false;
|
=> Embeds?.All(x => x.IsValid) ?? false;
|
||||||
|
|
||||||
|
@@ -1,16 +1,20 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace NadekoBot;
|
namespace NadekoBot;
|
||||||
|
|
||||||
public abstract record SmartText
|
public abstract record SmartText
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsEmbed
|
public bool IsEmbed
|
||||||
=> this is SmartEmbedText;
|
=> this is SmartEmbedText;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsPlainText
|
public bool IsPlainText
|
||||||
=> this is SmartPlainText;
|
=> this is SmartPlainText;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsEmbedArray
|
public bool IsEmbedArray
|
||||||
=> this is SmartEmbedTextArray;
|
=> this is SmartEmbedTextArray;
|
||||||
|
|
||||||
|
@@ -46,9 +46,7 @@ public sealed class CommandOrExprTypeReader : NadekoTypeReader<CommandOrExprInfo
|
|||||||
|
|
||||||
public override async ValueTask<TypeReaderResult<CommandOrExprInfo>> ReadAsync(ICommandContext ctx, string input)
|
public override async ValueTask<TypeReaderResult<CommandOrExprInfo>> ReadAsync(ICommandContext ctx, string input)
|
||||||
{
|
{
|
||||||
input = input.ToUpperInvariant();
|
if (_exprs.ExpressionExists(ctx.Guild?.Id, input))
|
||||||
|
|
||||||
if (_exprs.ExpressionExists(ctx.Guild?.Id, input) || _exprs.ExpressionExists(null, input))
|
|
||||||
return TypeReaderResult.FromSuccess(new CommandOrExprInfo(input, CommandOrExprInfo.Type.Custom));
|
return TypeReaderResult.FromSuccess(new CommandOrExprInfo(input, CommandOrExprInfo.Type.Custom));
|
||||||
|
|
||||||
var cmd = await new CommandTypeReader(_commandHandler, _cmds).ReadAsync(ctx, input);
|
var cmd = await new CommandTypeReader(_commandHandler, _cmds).ReadAsync(ctx, input);
|
||||||
|
@@ -12,10 +12,4 @@ public static class NadekoExpressionExtensions
|
|||||||
|
|
||||||
public static IEnumerable<NadekoExpression> ForId(this DbSet<NadekoExpression> exprs, ulong id)
|
public static IEnumerable<NadekoExpression> ForId(this DbSet<NadekoExpression> exprs, ulong id)
|
||||||
=> exprs.AsNoTracking().AsQueryable().Where(x => x.GuildId == id).ToList();
|
=> exprs.AsNoTracking().AsQueryable().Where(x => x.GuildId == id).ToList();
|
||||||
|
|
||||||
public static NadekoExpression GetByGuildIdAndInput(
|
|
||||||
this DbSet<NadekoExpression> exprs,
|
|
||||||
ulong? guildId,
|
|
||||||
string input)
|
|
||||||
=> exprs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
|
|
||||||
}
|
}
|
@@ -19,6 +19,7 @@ public class MuteService : INService
|
|||||||
|
|
||||||
private static readonly OverwritePermissions _denyOverwrite = new(addReactions: PermValue.Deny,
|
private static readonly OverwritePermissions _denyOverwrite = new(addReactions: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny,
|
sendMessages: PermValue.Deny,
|
||||||
|
sendMessagesInThreads: PermValue.Deny,
|
||||||
attachFiles: PermValue.Deny);
|
attachFiles: PermValue.Deny);
|
||||||
|
|
||||||
public event Action<IGuildUser, IUser, MuteType, string> UserMuted = delegate { };
|
public event Action<IGuildUser, IUser, MuteType, string> UserMuted = delegate { };
|
||||||
|
@@ -9,9 +9,9 @@ using NadekoBot.Services.Database.Models;
|
|||||||
namespace NadekoBot.Modules.Administration;
|
namespace NadekoBot.Modules.Administration;
|
||||||
|
|
||||||
public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||||
#if !GLOBAL_NADEKO
|
#if !GLOBAL_NADEKO
|
||||||
, INService // don't load this service on global nadeko
|
, INService // don't load this service on global nadeko
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public ConcurrentDictionary<ulong, LogSetting> GuildLogSettings { get; }
|
public ConcurrentDictionary<ulong, LogSetting> GuildLogSettings { get; }
|
||||||
|
|
||||||
@@ -49,15 +49,15 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
_prot = prot;
|
_prot = prot;
|
||||||
_tz = tz;
|
_tz = tz;
|
||||||
_punishService = punishService;
|
_punishService = punishService;
|
||||||
|
|
||||||
using (var uow = db.GetDbContext())
|
using (var uow = db.GetDbContext())
|
||||||
{
|
{
|
||||||
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
||||||
var configs = uow.LogSettings.AsQueryable()
|
var configs = uow.LogSettings.AsQueryable()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(x => guildIds.Contains(x.GuildId))
|
.Where(x => guildIds.Contains(x.GuildId))
|
||||||
.Include(ls => ls.LogIgnores)
|
.Include(ls => ls.LogIgnores)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
GuildLogSettings = configs.ToDictionary(ls => ls.GuildId).ToConcurrent();
|
GuildLogSettings = configs.ToDictionary(ls => ls.GuildId).ToConcurrent();
|
||||||
}
|
}
|
||||||
@@ -73,12 +73,13 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated;
|
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated;
|
||||||
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated_TTS;
|
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated_TTS;
|
||||||
_client.GuildMemberUpdated += _client_GuildUserUpdated;
|
_client.GuildMemberUpdated += _client_GuildUserUpdated;
|
||||||
|
_client.PresenceUpdated += _client_PresenceUpdated;
|
||||||
_client.UserUpdated += _client_UserUpdated;
|
_client.UserUpdated += _client_UserUpdated;
|
||||||
_client.ChannelCreated += _client_ChannelCreated;
|
_client.ChannelCreated += _client_ChannelCreated;
|
||||||
_client.ChannelDestroyed += _client_ChannelDestroyed;
|
_client.ChannelDestroyed += _client_ChannelDestroyed;
|
||||||
_client.ChannelUpdated += _client_ChannelUpdated;
|
_client.ChannelUpdated += _client_ChannelUpdated;
|
||||||
_client.RoleDeleted += _client_RoleDeleted;
|
_client.RoleDeleted += _client_RoleDeleted;
|
||||||
|
|
||||||
_client.ThreadCreated += _client_ThreadCreated;
|
_client.ThreadCreated += _client_ThreadCreated;
|
||||||
_client.ThreadDeleted += _client_ThreadDeleted;
|
_client.ThreadDeleted += _client_ThreadDeleted;
|
||||||
|
|
||||||
@@ -86,10 +87,63 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
_mute.UserUnmuted += MuteCommands_UserUnmuted;
|
_mute.UserUnmuted += MuteCommands_UserUnmuted;
|
||||||
|
|
||||||
_prot.OnAntiProtectionTriggered += TriggeredAntiProtection;
|
_prot.OnAntiProtectionTriggered += TriggeredAntiProtection;
|
||||||
|
|
||||||
_punishService.OnUserWarned += PunishServiceOnOnUserWarned;
|
_punishService.OnUserWarned += PunishServiceOnOnUserWarned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task _client_PresenceUpdated(SocketUser user, SocketPresence? before, SocketPresence? after)
|
||||||
|
{
|
||||||
|
if (user is not SocketGuildUser gu)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!GuildLogSettings.TryGetValue(gu.Guild.Id, out var logSetting)
|
||||||
|
|| before is null
|
||||||
|
|| after is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ITextChannel? logChannel;
|
||||||
|
|
||||||
|
if (!user.IsBot
|
||||||
|
&& logSetting.LogUserPresenceId is not null
|
||||||
|
&& (logChannel =
|
||||||
|
await TryGetLogChannel(gu.Guild, logSetting, LogType.UserPresence)) is not null)
|
||||||
|
{
|
||||||
|
if (before.Status != after.Status)
|
||||||
|
{
|
||||||
|
var str = "🎭"
|
||||||
|
+ Format.Code(PrettyCurrentTime(gu.Guild))
|
||||||
|
+ GetText(logChannel.Guild,
|
||||||
|
strs.user_status_change("👤" + Format.Bold(gu.Username),
|
||||||
|
Format.Bold(after.Status.ToString())));
|
||||||
|
PresenceUpdates.AddOrUpdate(logChannel,
|
||||||
|
new List<string>
|
||||||
|
{
|
||||||
|
str
|
||||||
|
},
|
||||||
|
(_, list) =>
|
||||||
|
{
|
||||||
|
list.Add(str);
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (before.Activities.FirstOrDefault()?.Name != after.Activities.FirstOrDefault()?.Name)
|
||||||
|
{
|
||||||
|
var str =
|
||||||
|
$"👾`{PrettyCurrentTime(gu.Guild)}`👤__**{gu.Username}**__ is now playing **{after.Activities.FirstOrDefault()?.Name ?? "-"}**.";
|
||||||
|
PresenceUpdates.AddOrUpdate(logChannel,
|
||||||
|
new List<string>
|
||||||
|
{
|
||||||
|
str
|
||||||
|
},
|
||||||
|
(_, list) =>
|
||||||
|
{
|
||||||
|
list.Add(str);
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Task _client_ThreadDeleted(Cacheable<SocketThreadChannel, ulong> sch)
|
private Task _client_ThreadDeleted(Cacheable<SocketThreadChannel, ulong> sch)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
@@ -139,7 +193,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
ITextChannel? logChannel;
|
ITextChannel? logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ThreadCreated)) is null)
|
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ThreadCreated)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var title = GetText(logChannel.Guild, strs.thread_created);
|
var title = GetText(logChannel.Guild, strs.thread_created);
|
||||||
|
|
||||||
await logChannel.EmbedAsync(_eb.Create()
|
await logChannel.EmbedAsync(_eb.Create()
|
||||||
@@ -177,22 +231,24 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
var keys = PresenceUpdates.Keys.ToList();
|
var keys = PresenceUpdates.Keys.ToList();
|
||||||
|
|
||||||
await keys.Select(key =>
|
await keys.Select(key =>
|
||||||
{
|
{
|
||||||
if (!((SocketGuild)key.Guild).CurrentUser.GetPermissions(key).SendMessages)
|
if (!((SocketGuild)key.Guild).CurrentUser.GetPermissions(key).SendMessages)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
if (PresenceUpdates.TryRemove(key, out var msgs))
|
if (PresenceUpdates.TryRemove(key, out var msgs))
|
||||||
{
|
{
|
||||||
var title = GetText(key.Guild, strs.presence_updates);
|
var title = GetText(key.Guild, strs.presence_updates);
|
||||||
var desc = string.Join(Environment.NewLine, msgs);
|
var desc = string.Join(Environment.NewLine, msgs);
|
||||||
return key.SendConfirmAsync(_eb, title, desc.TrimTo(2048)!);
|
return key.SendConfirmAsync(_eb, title, desc.TrimTo(2048)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
})
|
})
|
||||||
.WhenAll();
|
.WhenAll();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,35 +311,35 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
logSetting.UserLeftId = logSetting.UserBannedId = logSetting.UserUnbannedId = logSetting.UserUpdatedId =
|
logSetting.UserLeftId = logSetting.UserBannedId = logSetting.UserUnbannedId = logSetting.UserUpdatedId =
|
||||||
logSetting.ChannelCreatedId = logSetting.ChannelDestroyedId = logSetting.ChannelUpdatedId =
|
logSetting.ChannelCreatedId = logSetting.ChannelDestroyedId = logSetting.ChannelUpdatedId =
|
||||||
logSetting.LogUserPresenceId = logSetting.LogVoicePresenceId = logSetting.UserMutedId =
|
logSetting.LogUserPresenceId = logSetting.LogVoicePresenceId = logSetting.UserMutedId =
|
||||||
logSetting.LogVoicePresenceTTSId = value ? channelId : null;
|
logSetting.LogVoicePresenceTTSId = logSetting.ThreadCreatedId = logSetting.ThreadDeletedId
|
||||||
|
= logSetting.LogWarnsId = value ? channelId : null;
|
||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
GuildLogSettings.AddOrUpdate(guildId, _ => logSetting, (_, _) => logSetting);
|
GuildLogSettings.AddOrUpdate(guildId, _ => logSetting, (_, _) => logSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task PunishServiceOnOnUserWarned(Warning arg)
|
private async Task PunishServiceOnOnUserWarned(Warning arg)
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(arg.GuildId, out var logSetting) || logSetting.LogWarnsId is null)
|
if (!GuildLogSettings.TryGetValue(arg.GuildId, out var logSetting) || logSetting.LogWarnsId is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var g = _client.GetGuild(arg.GuildId);
|
var g = _client.GetGuild(arg.GuildId);
|
||||||
|
|
||||||
ITextChannel? logChannel;
|
ITextChannel? logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserWarned)) is null)
|
if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserWarned)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle($"⚠️ User Warned")
|
.WithTitle($"⚠️ User Warned")
|
||||||
.WithDescription($"<@{arg.UserId}> | {arg.UserId}")
|
.WithDescription($"<@{arg.UserId}> | {arg.UserId}")
|
||||||
.AddField("Mod", arg.Moderator)
|
.AddField("Mod", arg.Moderator)
|
||||||
.AddField("Reason", string.IsNullOrWhiteSpace(arg.Reason) ? "-" : arg.Reason, true)
|
.AddField("Reason", string.IsNullOrWhiteSpace(arg.Reason) ? "-" : arg.Reason, true)
|
||||||
.WithFooter(CurrentTime(g));
|
.WithFooter(CurrentTime(g));
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task _client_UserUpdated(SocketUser before, SocketUser uAfter)
|
private Task _client_UserUpdated(SocketUser before, SocketUser uAfter)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
@@ -307,18 +363,18 @@ 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.Discriminator} | {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))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
}
|
}
|
||||||
else if (before.AvatarId != after.AvatarId)
|
else if (before.AvatarId != after.AvatarId)
|
||||||
{
|
{
|
||||||
embed.WithTitle("👥" + GetText(g, strs.avatar_changed))
|
embed.WithTitle("👥" + GetText(g, strs.avatar_changed))
|
||||||
.WithDescription($"{before.Username}#{before.Discriminator} | {before.Id}")
|
.WithDescription($"{before.Username}#{before.Discriminator} | {before.Id}")
|
||||||
.WithFooter(CurrentTime(g))
|
.WithFooter(CurrentTime(g))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
var bav = before.RealAvatarUrl();
|
var bav = before.RealAvatarUrl();
|
||||||
if (bav.IsAbsoluteUri)
|
if (bav.IsAbsoluteUri)
|
||||||
@@ -482,10 +538,10 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithAuthor(mutes)
|
.WithAuthor(mutes)
|
||||||
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
||||||
.WithFooter(CurrentTime(usr.Guild))
|
.WithFooter(CurrentTime(usr.Guild))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
@@ -529,10 +585,10 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithAuthor(mutes)
|
.WithAuthor(mutes)
|
||||||
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
||||||
.WithFooter($"{CurrentTime(usr.Guild)}")
|
.WithFooter($"{CurrentTime(usr.Guild)}")
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(reason))
|
if (!string.IsNullOrWhiteSpace(reason))
|
||||||
embed.WithDescription(reason);
|
embed.WithDescription(reason);
|
||||||
@@ -583,11 +639,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithAuthor($"🛡 Anti-{protection}")
|
.WithAuthor($"🛡 Anti-{protection}")
|
||||||
.WithTitle(GetText(logChannel.Guild, strs.users) + " " + punishment)
|
.WithTitle(GetText(logChannel.Guild, strs.users) + " " + punishment)
|
||||||
.WithDescription(string.Join("\n", users.Select(u => u.ToString())))
|
.WithDescription(string.Join("\n", users.Select(u => u.ToString())))
|
||||||
.WithFooter(CurrentTime(logChannel.Guild))
|
.WithFooter(CurrentTime(logChannel.Guild))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
@@ -636,16 +692,16 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
&& (logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) is not null)
|
&& (logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) is not null)
|
||||||
{
|
{
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithFooter(CurrentTime(before.Guild))
|
.WithFooter(CurrentTime(before.Guild))
|
||||||
.WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}");
|
.WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}");
|
||||||
if (before.Nickname != after.Nickname)
|
if (before.Nickname != after.Nickname)
|
||||||
{
|
{
|
||||||
embed.WithAuthor("👥 " + GetText(logChannel.Guild, strs.nick_change))
|
embed.WithAuthor("👥 " + GetText(logChannel.Guild, strs.nick_change))
|
||||||
.AddField(GetText(logChannel.Guild, strs.old_nick),
|
.AddField(GetText(logChannel.Guild, strs.old_nick),
|
||||||
$"{before.Nickname}#{before.Discriminator}")
|
$"{before.Nickname}#{before.Discriminator}")
|
||||||
.AddField(GetText(logChannel.Guild, strs.new_nick),
|
.AddField(GetText(logChannel.Guild, strs.new_nick),
|
||||||
$"{after.Nickname}#{after.Discriminator}");
|
$"{after.Nickname}#{after.Discriminator}");
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
@@ -655,7 +711,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
{
|
{
|
||||||
var diffRoles = after.Roles.Where(r => !before.Roles.Contains(r)).Select(r => r.Name);
|
var diffRoles = after.Roles.Where(r => !before.Roles.Contains(r)).Select(r => r.Name);
|
||||||
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_add))
|
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_add))
|
||||||
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
@@ -663,59 +719,19 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
var diffRoles = before.Roles.Where(r => !after.Roles.Contains(r) && !IsRoleDeleted(r.Id))
|
var diffRoles = before.Roles.Where(r => !after.Roles.Contains(r) && !IsRoleDeleted(r.Id))
|
||||||
.Select(r => r.Name)
|
.Select(r => r.Name)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (diffRoles.Any())
|
if (diffRoles.Any())
|
||||||
{
|
{
|
||||||
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_rem))
|
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_rem))
|
||||||
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!before.IsBot
|
|
||||||
&& logSetting.LogUserPresenceId is not null
|
|
||||||
&& (logChannel =
|
|
||||||
await TryGetLogChannel(before.Guild, logSetting, LogType.UserPresence)) is not null)
|
|
||||||
{
|
|
||||||
if (before.Status != after.Status)
|
|
||||||
{
|
|
||||||
var str = "🎭"
|
|
||||||
+ Format.Code(PrettyCurrentTime(after.Guild))
|
|
||||||
+ GetText(logChannel.Guild,
|
|
||||||
strs.user_status_change("👤" + Format.Bold(after.Username),
|
|
||||||
Format.Bold(after.Status.ToString())));
|
|
||||||
PresenceUpdates.AddOrUpdate(logChannel,
|
|
||||||
new List<string>
|
|
||||||
{
|
|
||||||
str
|
|
||||||
},
|
|
||||||
(_, list) =>
|
|
||||||
{
|
|
||||||
list.Add(str);
|
|
||||||
return list;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (before.Activities.FirstOrDefault()?.Name != after.Activities.FirstOrDefault()?.Name)
|
|
||||||
{
|
|
||||||
var str =
|
|
||||||
$"👾`{PrettyCurrentTime(after.Guild)}`👤__**{after.Username}**__ is now playing **{after.Activities.FirstOrDefault()?.Name ?? "-"}**.";
|
|
||||||
PresenceUpdates.AddOrUpdate(logChannel,
|
|
||||||
new List<string>
|
|
||||||
{
|
|
||||||
str
|
|
||||||
},
|
|
||||||
(_, list) =>
|
|
||||||
{
|
|
||||||
list.Add(str);
|
|
||||||
return list;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -754,15 +770,15 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
if (before.Name != after.Name)
|
if (before.Name != after.Name)
|
||||||
{
|
{
|
||||||
embed.WithTitle("ℹ️ " + GetText(logChannel.Guild, strs.ch_name_change))
|
embed.WithTitle("ℹ️ " + GetText(logChannel.Guild, strs.ch_name_change))
|
||||||
.WithDescription($"{after} | {after.Id}")
|
.WithDescription($"{after} | {after.Id}")
|
||||||
.AddField(GetText(logChannel.Guild, strs.ch_old_name), before.Name);
|
.AddField(GetText(logChannel.Guild, strs.ch_old_name), before.Name);
|
||||||
}
|
}
|
||||||
else if (beforeTextChannel?.Topic != afterTextChannel?.Topic)
|
else if (beforeTextChannel?.Topic != afterTextChannel?.Topic)
|
||||||
{
|
{
|
||||||
embed.WithTitle("ℹ️ " + GetText(logChannel.Guild, strs.ch_topic_change))
|
embed.WithTitle("ℹ️ " + GetText(logChannel.Guild, strs.ch_topic_change))
|
||||||
.WithDescription($"{after} | {after.Id}")
|
.WithDescription($"{after} | {after.Id}")
|
||||||
.AddField(GetText(logChannel.Guild, strs.old_topic), beforeTextChannel?.Topic ?? "-")
|
.AddField(GetText(logChannel.Guild, strs.old_topic), beforeTextChannel?.Topic ?? "-")
|
||||||
.AddField(GetText(logChannel.Guild, strs.new_topic), afterTextChannel?.Topic ?? "-");
|
.AddField(GetText(logChannel.Guild, strs.new_topic), afterTextChannel?.Topic ?? "-");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@@ -795,7 +811,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
ITextChannel? logChannel;
|
ITextChannel? logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) is null)
|
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string title;
|
string title;
|
||||||
if (ch is IVoiceChannel)
|
if (ch is IVoiceChannel)
|
||||||
title = GetText(logChannel.Guild, strs.voice_chan_destroyed);
|
title = GetText(logChannel.Guild, strs.voice_chan_destroyed);
|
||||||
@@ -803,10 +819,10 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
title = GetText(logChannel.Guild, strs.text_chan_destroyed);
|
title = GetText(logChannel.Guild, strs.text_chan_destroyed);
|
||||||
|
|
||||||
await logChannel.EmbedAsync(_eb.Create()
|
await logChannel.EmbedAsync(_eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("🆕 " + title)
|
.WithTitle("🆕 " + title)
|
||||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||||
.WithFooter(CurrentTime(ch.Guild)));
|
.WithFooter(CurrentTime(ch.Guild)));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -815,7 +831,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task _client_ChannelCreated(IChannel ich)
|
private Task _client_ChannelCreated(IChannel ich)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
@@ -839,10 +855,10 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
title = GetText(logChannel.Guild, strs.text_chan_created);
|
title = GetText(logChannel.Guild, strs.text_chan_created);
|
||||||
|
|
||||||
await logChannel.EmbedAsync(_eb.Create()
|
await logChannel.EmbedAsync(_eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("🆕 " + title)
|
.WithTitle("🆕 " + title)
|
||||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||||
.WithFooter(CurrentTime(ch.Guild)));
|
.WithFooter(CurrentTime(ch.Guild)));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -942,11 +958,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserLeft)) is null)
|
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserLeft)) is null)
|
||||||
return;
|
return;
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("❌ " + GetText(logChannel.Guild, strs.user_left))
|
.WithTitle("❌ " + GetText(logChannel.Guild, strs.user_left))
|
||||||
.WithDescription(usr.ToString())
|
.WithDescription(usr.ToString())
|
||||||
.AddField("Id", usr.Id.ToString())
|
.AddField("Id", usr.Id.ToString())
|
||||||
.WithFooter(CurrentTime(guild));
|
.WithFooter(CurrentTime(guild));
|
||||||
|
|
||||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||||
@@ -975,17 +991,17 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("✅ " + GetText(logChannel.Guild, strs.user_joined))
|
.WithTitle("✅ " + GetText(logChannel.Guild, strs.user_joined))
|
||||||
.WithDescription($"{usr.Mention} `{usr}`")
|
.WithDescription($"{usr.Mention} `{usr}`")
|
||||||
.AddField("Id", usr.Id.ToString())
|
.AddField("Id", usr.Id.ToString())
|
||||||
.AddField(GetText(logChannel.Guild, strs.joined_server),
|
.AddField(GetText(logChannel.Guild, strs.joined_server),
|
||||||
$"{usr.JoinedAt?.ToString("dd.MM.yyyy HH:mm") ?? "?"}",
|
$"{usr.JoinedAt?.ToString("dd.MM.yyyy HH:mm") ?? "?"}",
|
||||||
true)
|
true)
|
||||||
.AddField(GetText(logChannel.Guild, strs.joined_discord),
|
.AddField(GetText(logChannel.Guild, strs.joined_discord),
|
||||||
$"{usr.CreatedAt:dd.MM.yyyy HH:mm}",
|
$"{usr.CreatedAt:dd.MM.yyyy HH:mm}",
|
||||||
true)
|
true)
|
||||||
.WithFooter(CurrentTime(usr.Guild));
|
.WithFooter(CurrentTime(usr.Guild));
|
||||||
|
|
||||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||||
@@ -1016,11 +1032,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) is null)
|
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) is null)
|
||||||
return;
|
return;
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("♻️ " + GetText(logChannel.Guild, strs.user_unbanned))
|
.WithTitle("♻️ " + GetText(logChannel.Guild, strs.user_unbanned))
|
||||||
.WithDescription(usr.ToString()!)
|
.WithDescription(usr.ToString()!)
|
||||||
.AddField("Id", usr.Id.ToString())
|
.AddField("Id", usr.Id.ToString())
|
||||||
.WithFooter(CurrentTime(guild));
|
.WithFooter(CurrentTime(guild));
|
||||||
|
|
||||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||||
@@ -1060,16 +1076,15 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("🚫 " + GetText(logChannel.Guild, strs.user_banned))
|
.WithTitle("🚫 " + GetText(logChannel.Guild, strs.user_banned))
|
||||||
.WithDescription(usr.ToString()!)
|
.WithDescription(usr.ToString()!)
|
||||||
.AddField("Id", usr.Id.ToString())
|
.AddField("Id", usr.Id.ToString())
|
||||||
.AddField("Reason", string.IsNullOrWhiteSpace(reason) ? "-" : reason)
|
.AddField("Reason", string.IsNullOrWhiteSpace(reason) ? "-" : reason)
|
||||||
.WithFooter(CurrentTime(guild));
|
.WithFooter(CurrentTime(guild));
|
||||||
|
|
||||||
var avatarUrl = usr.GetAvatarUrl();
|
var avatarUrl = usr.GetAvatarUrl();
|
||||||
|
|
||||||
@@ -1115,14 +1130,14 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
|
|
||||||
var resolvedMessage = msg.Resolve(TagHandling.FullName);
|
var resolvedMessage = msg.Resolve(TagHandling.FullName);
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("🗑 "
|
.WithTitle("🗑 "
|
||||||
+ GetText(logChannel.Guild, strs.msg_del(((ITextChannel)msg.Channel).Name)))
|
+ GetText(logChannel.Guild, strs.msg_del(((ITextChannel)msg.Channel).Name)))
|
||||||
.WithDescription(msg.Author.ToString()!)
|
.WithDescription(msg.Author.ToString()!)
|
||||||
.AddField(GetText(logChannel.Guild, strs.content),
|
.AddField(GetText(logChannel.Guild, strs.content),
|
||||||
string.IsNullOrWhiteSpace(resolvedMessage) ? "-" : resolvedMessage)
|
string.IsNullOrWhiteSpace(resolvedMessage) ? "-" : resolvedMessage)
|
||||||
.AddField("Id", msg.Id.ToString())
|
.AddField("Id", msg.Id.ToString())
|
||||||
.WithFooter(CurrentTime(channel.Guild));
|
.WithFooter(CurrentTime(channel.Guild));
|
||||||
if (msg.Attachments.Any())
|
if (msg.Attachments.Any())
|
||||||
{
|
{
|
||||||
embed.AddField(GetText(logChannel.Guild, strs.attachments),
|
embed.AddField(GetText(logChannel.Guild, strs.attachments),
|
||||||
@@ -1175,19 +1190,19 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = _eb.Create()
|
var embed = _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle("📝 "
|
.WithTitle("📝 "
|
||||||
+ GetText(logChannel.Guild,
|
+ GetText(logChannel.Guild,
|
||||||
strs.msg_update(((ITextChannel)after.Channel).Name)))
|
strs.msg_update(((ITextChannel)after.Channel).Name)))
|
||||||
.WithDescription(after.Author.ToString()!)
|
.WithDescription(after.Author.ToString()!)
|
||||||
.AddField(GetText(logChannel.Guild, strs.old_msg),
|
.AddField(GetText(logChannel.Guild, strs.old_msg),
|
||||||
string.IsNullOrWhiteSpace(before.Content)
|
string.IsNullOrWhiteSpace(before.Content)
|
||||||
? "-"
|
? "-"
|
||||||
: before.Resolve(TagHandling.FullName))
|
: before.Resolve(TagHandling.FullName))
|
||||||
.AddField(GetText(logChannel.Guild, strs.new_msg),
|
.AddField(GetText(logChannel.Guild, strs.new_msg),
|
||||||
string.IsNullOrWhiteSpace(after.Content) ? "-" : after.Resolve(TagHandling.FullName))
|
string.IsNullOrWhiteSpace(after.Content) ? "-" : after.Resolve(TagHandling.FullName))
|
||||||
.AddField("Id", after.Id.ToString())
|
.AddField("Id", after.Id.ToString())
|
||||||
.WithFooter(CurrentTime(channel.Guild));
|
.WithFooter(CurrentTime(channel.Guild));
|
||||||
|
|
||||||
await logChannel.EmbedAsync(embed);
|
await logChannel.EmbedAsync(embed);
|
||||||
}
|
}
|
||||||
|
@@ -34,14 +34,14 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
";
|
";
|
||||||
|
|
||||||
private static readonly ISerializer _exportSerializer = new SerializerBuilder()
|
private static readonly ISerializer _exportSerializer = new SerializerBuilder()
|
||||||
.WithEventEmitter(args
|
.WithEventEmitter(args
|
||||||
=> new MultilineScalarFlowStyleEmitter(args))
|
=> new MultilineScalarFlowStyleEmitter(args))
|
||||||
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
||||||
.WithIndentedSequences()
|
.WithIndentedSequences()
|
||||||
.ConfigureDefaultValuesHandling(DefaultValuesHandling
|
.ConfigureDefaultValuesHandling(DefaultValuesHandling
|
||||||
.OmitDefaults)
|
.OmitDefaults)
|
||||||
.DisableAliases()
|
.DisableAliases()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
public int Priority
|
public int Priority
|
||||||
=> 0;
|
=> 0;
|
||||||
@@ -57,8 +57,8 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
// 1. expressions are almost never added (compared to how many times they are being looped through)
|
// 1. expressions are almost never added (compared to how many times they are being looped through)
|
||||||
// 2. only need write locks for this as we'll rebuild+replace the array on every edit
|
// 2. only need write locks for this as we'll rebuild+replace the array on every edit
|
||||||
// 3. there's never many of them (at most a thousand, usually < 100)
|
// 3. there's never many of them (at most a thousand, usually < 100)
|
||||||
private NadekoExpression[] globalExpressions;
|
private NadekoExpression[] globalExpressions = Array.Empty<NadekoExpression>();
|
||||||
private ConcurrentDictionary<ulong, NadekoExpression[]> newguildExpressions;
|
private ConcurrentDictionary<ulong, NadekoExpression[]> newguildExpressions = new();
|
||||||
|
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
@@ -112,20 +112,20 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
{
|
{
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
var guildItems = await uow.Expressions.AsNoTracking()
|
var guildItems = await uow.Expressions.AsNoTracking()
|
||||||
.Where(x => allGuildIds.Contains(x.GuildId.Value))
|
.Where(x => allGuildIds.Contains(x.GuildId.Value))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
newguildExpressions = guildItems.GroupBy(k => k.GuildId!.Value)
|
newguildExpressions = guildItems.GroupBy(k => k.GuildId!.Value)
|
||||||
.ToDictionary(g => g.Key,
|
.ToDictionary(g => g.Key,
|
||||||
g => g.Select(x =>
|
g => g.Select(x =>
|
||||||
{
|
{
|
||||||
x.Trigger = x.Trigger.Replace(MENTION_PH, _bot.Mention);
|
x.Trigger = x.Trigger.Replace(MENTION_PH, _bot.Mention);
|
||||||
return x;
|
return x;
|
||||||
})
|
})
|
||||||
.ToArray())
|
.ToArray())
|
||||||
.ToConcurrent();
|
.ToConcurrent();
|
||||||
|
|
||||||
_disabledGlobalExpressionGuilds = new (await uow.GuildConfigs
|
_disabledGlobalExpressionGuilds = new(await uow.GuildConfigs
|
||||||
.Where(x => x.DisableGlobalExpressions)
|
.Where(x => x.DisableGlobalExpressions)
|
||||||
.Select(x => x.GuildId)
|
.Select(x => x.GuildId)
|
||||||
.ToListAsyncLinqToDB());
|
.ToListAsyncLinqToDB());
|
||||||
@@ -133,14 +133,14 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
lock (_gexprWriteLock)
|
lock (_gexprWriteLock)
|
||||||
{
|
{
|
||||||
var globalItems = uow.Expressions.AsNoTracking()
|
var globalItems = uow.Expressions.AsNoTracking()
|
||||||
.Where(x => x.GuildId == null || x.GuildId == 0)
|
.Where(x => x.GuildId == null || x.GuildId == 0)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
x.Trigger = x.Trigger.Replace(MENTION_PH, _bot.Mention);
|
x.Trigger = x.Trigger.Replace(MENTION_PH, _bot.Mention);
|
||||||
return x;
|
return x;
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
globalExpressions = globalItems;
|
globalExpressions = globalItems;
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
|
|
||||||
if (_disabledGlobalExpressionGuilds.Contains(channel.Guild.Id))
|
if (_disabledGlobalExpressionGuilds.Contains(channel.Guild.Id))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var localGrs = globalExpressions;
|
var localGrs = globalExpressions;
|
||||||
|
|
||||||
return MatchExpressions(content, localGrs);
|
return MatchExpressions(content, localGrs);
|
||||||
@@ -466,7 +466,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
await using (var uow = _db.GetDbContext())
|
await using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
expr = uow.Expressions.GetById(id);
|
expr = uow.Expressions.GetById(id);
|
||||||
|
|
||||||
if (expr is null || expr.GuildId != guildId)
|
if (expr is null || expr.GuildId != guildId)
|
||||||
return (false, false);
|
return (false, false);
|
||||||
if (field == ExprField.AutoDelete)
|
if (field == ExprField.AutoDelete)
|
||||||
@@ -509,9 +509,25 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
|
|
||||||
public bool ExpressionExists(ulong? guildId, string input)
|
public bool ExpressionExists(ulong? guildId, string input)
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
input = input.ToLowerInvariant();
|
||||||
var expr = uow.Expressions.GetByGuildIdAndInput(guildId, input);
|
|
||||||
return expr is not null;
|
var gexprs = globalExpressions;
|
||||||
|
foreach (var t in gexprs)
|
||||||
|
{
|
||||||
|
if (t.Trigger == input)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (guildId is ulong gid && newguildExpressions.TryGetValue(gid, out var guildExprs))
|
||||||
|
{
|
||||||
|
foreach (var t in guildExprs)
|
||||||
|
{
|
||||||
|
if (t.Trigger == input)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ExportExpressions(ulong? guildId)
|
public string ExportExpressions(ulong? guildId)
|
||||||
@@ -542,17 +558,17 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
{
|
{
|
||||||
var trigger = entry.Key;
|
var trigger = entry.Key;
|
||||||
await uow.Expressions.AddRangeAsync(entry.Value.Where(expr => !string.IsNullOrWhiteSpace(expr.Res))
|
await uow.Expressions.AddRangeAsync(entry.Value.Where(expr => !string.IsNullOrWhiteSpace(expr.Res))
|
||||||
.Select(expr => new NadekoExpression
|
.Select(expr => new NadekoExpression
|
||||||
{
|
{
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
Response = expr.Res,
|
Response = expr.Res,
|
||||||
Reactions = expr.React?.Join("@@@"),
|
Reactions = expr.React?.Join("@@@"),
|
||||||
Trigger = trigger,
|
Trigger = trigger,
|
||||||
AllowTarget = expr.At,
|
AllowTarget = expr.At,
|
||||||
ContainsAnywhere = expr.Ca,
|
ContainsAnywhere = expr.Ca,
|
||||||
DmResponse = expr.Dm,
|
DmResponse = expr.Dm,
|
||||||
AutoDeleteTrigger = expr.Ad
|
AutoDeleteTrigger = expr.Ad
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
@@ -725,12 +741,12 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
var gc = ctx.GuildConfigsForId(guildId, set => set);
|
var gc = ctx.GuildConfigsForId(guildId, set => set);
|
||||||
var toReturn = gc.DisableGlobalExpressions = !gc.DisableGlobalExpressions;
|
var toReturn = gc.DisableGlobalExpressions = !gc.DisableGlobalExpressions;
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
|
|
||||||
if (toReturn)
|
if (toReturn)
|
||||||
_disabledGlobalExpressionGuilds.Add(guildId);
|
_disabledGlobalExpressionGuilds.Add(guildId);
|
||||||
else
|
else
|
||||||
_disabledGlobalExpressionGuilds.TryRemove(guildId);
|
_disabledGlobalExpressionGuilds.TryRemove(guildId);
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -77,28 +77,24 @@ public partial class Gambling
|
|||||||
{
|
{
|
||||||
if (await _bank.TakeAsync(userId, amount))
|
if (await _bank.TakeAsync(userId, amount))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.take_fail(N(amount),
|
await ctx.OkAsync();
|
||||||
_client.GetUser(userId)?.ToString()
|
|
||||||
?? userId.ToString(),
|
|
||||||
CurrencySign));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ctx.OkAsync();
|
await ReplyErrorLocalizedAsync(strs.take_fail(N(amount),
|
||||||
|
_client.GetUser(userId)?.ToString()
|
||||||
|
?? userId.ToString(),
|
||||||
|
CurrencySign));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task BankAwardInternalAsync(long amount, ulong userId)
|
private async Task BankAwardInternalAsync(long amount, ulong userId)
|
||||||
{
|
{
|
||||||
if (await _bank.AwardAsync(userId, amount))
|
if (await _bank.AwardAsync(userId, amount))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.take_fail(N(amount),
|
await ctx.OkAsync();
|
||||||
_client.GetUser(userId)?.ToString()
|
|
||||||
?? userId.ToString(),
|
|
||||||
CurrencySign));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ctx.OkAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
@@ -840,7 +840,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
else if (result.Result == RpsResultType.Win)
|
else if (result.Result == RpsResultType.Win)
|
||||||
{
|
{
|
||||||
if ((long)result.Won > 0)
|
if ((long)result.Won > 0)
|
||||||
embed.AddField(GetText(strs.won), N(amount.Value));
|
embed.AddField(GetText(strs.won), N((long)result.Won));
|
||||||
|
|
||||||
msg = GetText(strs.rps_win(ctx.User.Mention,
|
msg = GetText(strs.rps_win(ctx.User.Mention,
|
||||||
GetRpsPick(pick),
|
GetRpsPick(pick),
|
||||||
|
@@ -108,10 +108,10 @@ public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
|||||||
public sealed partial class ChatGptConfig
|
public sealed partial class ChatGptConfig
|
||||||
{
|
{
|
||||||
[Comment(@"Which GPT-3 Model should bot use.
|
[Comment(@"Which GPT-3 Model should bot use.
|
||||||
'ada' - cheapest and fastest
|
'ada001' - cheapest and fastest
|
||||||
'babbage' - 2nd option
|
'babbage001' - 2nd option
|
||||||
'curie' - 3rd option
|
'curie001' - 3rd option
|
||||||
'davinci' - Most expensive, slowest")]
|
'davinci003' - Most expensive, slowest")]
|
||||||
public Gpt3Model Model { get; set; } = Gpt3Model.Ada001;
|
public Gpt3Model Model { get; set; } = Gpt3Model.Ada001;
|
||||||
|
|
||||||
[Comment(@"The maximum number of tokens to use per GPT-3 API call")]
|
[Comment(@"The maximum number of tokens to use per GPT-3 API call")]
|
||||||
|
@@ -36,7 +36,7 @@ public partial class Games
|
|||||||
var (opts, _) = OptionsParser.ParseFrom(new TriviaOptions(), args);
|
var (opts, _) = OptionsParser.ParseFrom(new TriviaOptions(), args);
|
||||||
|
|
||||||
var config = _gamesConfig.Data;
|
var config = _gamesConfig.Data;
|
||||||
if (config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement)
|
if (opts.WinRequirement != 0 && config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var trivia = new TriviaGame(opts, _cache);
|
var trivia = new TriviaGame(opts, _cache);
|
||||||
|
@@ -157,7 +157,7 @@ public sealed class TriviaGame
|
|||||||
|
|
||||||
var isWin = false;
|
var isWin = false;
|
||||||
// if user won the game, tell the game to stop
|
// if user won the game, tell the game to stop
|
||||||
if (val >= _opts.WinRequirement)
|
if (_opts.WinRequirement != 0 && val >= _opts.WinRequirement)
|
||||||
{
|
{
|
||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
isWin = true;
|
isWin = true;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using NadekoBot.Modules.Searches;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Music;
|
namespace NadekoBot.Modules.Music;
|
||||||
|
|
||||||
@@ -27,10 +28,11 @@ public sealed class YtdlYoutubeResolver : IYoutubeResolver
|
|||||||
|
|
||||||
private readonly IGoogleApiService _google;
|
private readonly IGoogleApiService _google;
|
||||||
|
|
||||||
public YtdlYoutubeResolver(ITrackCacher trackCacher, IGoogleApiService google)
|
public YtdlYoutubeResolver(ITrackCacher trackCacher, IGoogleApiService google, SearchesConfigService scs)
|
||||||
{
|
{
|
||||||
_trackCacher = trackCacher;
|
_trackCacher = trackCacher;
|
||||||
_google = google;
|
_google = google;
|
||||||
|
|
||||||
|
|
||||||
_ytdlPlaylistOperation = new("-4 "
|
_ytdlPlaylistOperation = new("-4 "
|
||||||
+ "--geo-bypass "
|
+ "--geo-bypass "
|
||||||
@@ -44,7 +46,7 @@ public sealed class YtdlYoutubeResolver : IYoutubeResolver
|
|||||||
+ "--no-check-certificate "
|
+ "--no-check-certificate "
|
||||||
+ "-i "
|
+ "-i "
|
||||||
+ "--yes-playlist "
|
+ "--yes-playlist "
|
||||||
+ "-- \"{0}\"");
|
+ "-- \"{0}\"", scs.Data.YtProvider != YoutubeSearcher.Ytdl);
|
||||||
|
|
||||||
_ytdlIdOperation = new("-4 "
|
_ytdlIdOperation = new("-4 "
|
||||||
+ "--geo-bypass "
|
+ "--geo-bypass "
|
||||||
@@ -56,7 +58,7 @@ public sealed class YtdlYoutubeResolver : IYoutubeResolver
|
|||||||
+ "--get-thumbnail "
|
+ "--get-thumbnail "
|
||||||
+ "--get-duration "
|
+ "--get-duration "
|
||||||
+ "--no-check-certificate "
|
+ "--no-check-certificate "
|
||||||
+ "-- \"{0}\"");
|
+ "-- \"{0}\"", scs.Data.YtProvider != YoutubeSearcher.Ytdl);
|
||||||
|
|
||||||
_ytdlSearchOperation = new("-4 "
|
_ytdlSearchOperation = new("-4 "
|
||||||
+ "--geo-bypass "
|
+ "--geo-bypass "
|
||||||
@@ -69,7 +71,7 @@ public sealed class YtdlYoutubeResolver : IYoutubeResolver
|
|||||||
+ "--get-duration "
|
+ "--get-duration "
|
||||||
+ "--no-check-certificate "
|
+ "--no-check-certificate "
|
||||||
+ "--default-search "
|
+ "--default-search "
|
||||||
+ "\"ytsearch:\" -- \"{0}\"");
|
+ "\"ytsearch:\" -- \"{0}\"", scs.Data.YtProvider != YoutubeSearcher.Ytdl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private YtTrackData ResolveYtdlData(string ytdlOutputString)
|
private YtTrackData ResolveYtdlData(string ytdlOutputString)
|
||||||
|
@@ -39,7 +39,7 @@ public partial class Searches
|
|||||||
[Cmd]
|
[Cmd]
|
||||||
public async Task MagicItem()
|
public async Task MagicItem()
|
||||||
{
|
{
|
||||||
if (!_service.WowJokes.Any())
|
if (!_service.MagicItems.Any())
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.magicitems_not_loaded);
|
await ReplyErrorLocalizedAsync(strs.magicitems_not_loaded);
|
||||||
return;
|
return;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using NadekoBot.Modules.Administration.Services;
|
using NadekoBot.Modules.Administration.Services;
|
||||||
using NadekoBot.Modules.Searches.Common;
|
using NadekoBot.Modules.Searches.Common;
|
||||||
@@ -199,7 +199,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
|||||||
if (!await ValidateQuery(ffs))
|
if (!await ValidateQuery(ffs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var shortenedUrl = await _google.ShortenUrl($"https://lmgtfy.com/?q={Uri.EscapeDataString(ffs)}");
|
var shortenedUrl = await _google.ShortenUrl($"https://letmegooglethat.com/?q={Uri.EscapeDataString(ffs)}");
|
||||||
await SendConfirmAsync($"<{shortenedUrl}>");
|
await SendConfirmAsync($"<{shortenedUrl}>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
|||||||
return _eb.Create()
|
return _eb.Create()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithUrl(item.Permalink)
|
.WithUrl(item.Permalink)
|
||||||
.WithAuthor(item.Word)
|
.WithTitle(item.Word)
|
||||||
.WithDescription(item.Definition);
|
.WithDescription(item.Definition);
|
||||||
},
|
},
|
||||||
items.Length,
|
items.Length,
|
||||||
@@ -612,4 +612,4 @@ public partial class Searches : NadekoModule<SearchesService>
|
|||||||
[JsonProperty("result_url")]
|
[JsonProperty("result_url")]
|
||||||
public string ResultUrl { get; set; }
|
public string ResultUrl { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -296,8 +296,8 @@ public class SearchesService : INService
|
|||||||
public async Task<string> GetChuckNorrisJoke()
|
public async Task<string> GetChuckNorrisJoke()
|
||||||
{
|
{
|
||||||
using var http = _httpFactory.CreateClient();
|
using var http = _httpFactory.CreateClient();
|
||||||
var response = await http.GetStringAsync(new Uri("http://api.icndb.com/jokes/random/"));
|
var response = await http.GetStringAsync(new Uri("https://api.chucknorris.io/jokes/random"));
|
||||||
return JObject.Parse(response)["value"]["joke"] + " 😆";
|
return JObject.Parse(response)["value"] + " 😆";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MtgData> GetMtgCardAsync(string search)
|
public async Task<MtgData> GetMtgCardAsync(string search)
|
||||||
|
@@ -550,15 +550,20 @@ public partial class Utility : NadekoModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var embed = msg.Embeds.FirstOrDefault();
|
if (!msg.Embeds.Any())
|
||||||
if (embed is null)
|
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = SmartEmbedText.FromEmbed(embed, msg.Content).ToJson(_showEmbedSerializerOptions);
|
var json = new SmartEmbedTextArray()
|
||||||
await SendConfirmAsync(Format.Sanitize(json).Replace("](", "]\\("));
|
{
|
||||||
|
Content = msg.Content,
|
||||||
|
Embeds = msg.Embeds
|
||||||
|
.Map(x => new SmartEmbedArrayElementText(x))
|
||||||
|
}.ToJson(_showEmbedSerializerOptions);
|
||||||
|
|
||||||
|
await SendConfirmAsync(Format.Code(json, "json").Replace("](", "]\\("));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
@@ -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.12";
|
public const string BOT_VERSION = "4.3.15";
|
||||||
|
|
||||||
public string Author
|
public string Author
|
||||||
=> "Kwoth#2452";
|
=> "Kwoth#2452";
|
||||||
|
@@ -1559,7 +1559,7 @@ timezones:
|
|||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
timezone:
|
timezone:
|
||||||
desc: "Sets this guilds timezone. This affects bot's time output in this server (logs, etc..)"
|
desc: "Sets this guilds timezone. This affects bot's time output in this server (logs, etc..) **Setting timezone requires Administrator server permission.**"
|
||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
- "GMT Standard Time"
|
- "GMT Standard Time"
|
||||||
|
@@ -237,20 +237,25 @@ namespace Ayu.Discord.Voice
|
|||||||
_udpEp = new(IPAddress.Parse(ready.Ip), ready.Port);
|
_udpEp = new(IPAddress.Parse(ready.Ip), ready.Port);
|
||||||
|
|
||||||
var ssrcBytes = BitConverter.GetBytes(Ssrc);
|
var ssrcBytes = BitConverter.GetBytes(Ssrc);
|
||||||
var ipDiscoveryData = new byte[70];
|
Array.Reverse(ssrcBytes);
|
||||||
Buffer.BlockCopy(ssrcBytes, 0, ipDiscoveryData, 0, ssrcBytes.Length);
|
var ipDiscoveryData = new byte[74];
|
||||||
|
Buffer.BlockCopy(ssrcBytes, 0, ipDiscoveryData, 4, ssrcBytes.Length);
|
||||||
|
ipDiscoveryData[0] = 0x00;
|
||||||
|
ipDiscoveryData[1] = 0x01;
|
||||||
|
ipDiscoveryData[2] = 0x00;
|
||||||
|
ipDiscoveryData[3] = 0x46;
|
||||||
await _udpClient.SendAsync(ipDiscoveryData, ipDiscoveryData.Length, _udpEp);
|
await _udpClient.SendAsync(ipDiscoveryData, ipDiscoveryData.Length, _udpEp);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var buffer = _udpClient.Receive(ref _udpEp);
|
var buffer = _udpClient.Receive(ref _udpEp);
|
||||||
|
|
||||||
if (buffer.Length == 70)
|
if (buffer.Length == 74)
|
||||||
{
|
{
|
||||||
//Log.Information("Received IP discovery data.");
|
//Log.Information("Received IP discovery data.");
|
||||||
|
|
||||||
var myIp = Encoding.UTF8.GetString(buffer, 4, buffer.Length - 8);
|
var myIp = Encoding.UTF8.GetString(buffer, 8, buffer.Length - 10);
|
||||||
MyIp = myIp.TrimEnd('\0');
|
MyIp = myIp.TrimEnd('\0');
|
||||||
MyPort = BitConverter.ToUInt16(buffer, buffer.Length - 2);
|
MyPort = (ushort)((buffer[^2] << 8) | buffer[^1]);
|
||||||
|
|
||||||
//Log.Information("{MyIp}:{MyPort}", MyIp, MyPort);
|
//Log.Information("{MyIp}:{MyPort}", MyIp, MyPort);
|
||||||
|
|
||||||
@@ -367,4 +372,4 @@ namespace Ayu.Discord.Voice
|
|||||||
await complete.Task;
|
await complete.Task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user