fixed .antispamignore
Improved livechannel error handling
This commit is contained in:
parent
134e5a8c92
commit
d9d35420c9
8 changed files with 46 additions and 25 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -2,7 +2,21 @@
|
||||||
|
|
||||||
*a,c,f,r,o*
|
*a,c,f,r,o*
|
||||||
|
|
||||||
## [6.0.7] - 18.03.2025
|
## [6.0.8] - 19.03.2025
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Live channel commands
|
||||||
|
- `.lcha` adds a channel with a template message (supports placeholders, and works on category channels too!)
|
||||||
|
- Every 10 minutes, channel name will be updated
|
||||||
|
- example: `.lcha #my-channel --> Members: %server.members% <--` will display the number of members in the server as a channel name, updating once every 10 minutes
|
||||||
|
- `.lchl` lists all live channels (Up to 5)
|
||||||
|
- `.lchd <channel or channelId>` removed a live channel
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `.antispamignore` fixed
|
||||||
|
|
||||||
|
## [6.0.7] - 19.03.2025
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>true</ImplicitUsings>
|
<ImplicitUsings>true</ImplicitUsings>
|
||||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||||
<Version>6.0.7</Version>
|
<Version>6.0.8</Version>
|
||||||
|
|
||||||
<!-- Output/build -->
|
<!-- Output/build -->
|
||||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
using System.Net;
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using EllieBot.Common.ModuleBehaviors;
|
using EllieBot.Common.ModuleBehaviors;
|
||||||
|
@ -248,23 +249,21 @@ public class MuteService : IEService, IReadyExecutor
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(guild);
|
ArgumentNullException.ThrowIfNull(guild);
|
||||||
|
|
||||||
const string defaultMuteRoleName = "nadeko-mute";
|
const string defaultMuteRoleName = "ellie-mute";
|
||||||
|
|
||||||
var muteRoleName = _guildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
|
var muteRoleName = _guildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
|
||||||
|
|
||||||
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
|
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
|
||||||
if (muteRole is null)
|
if (muteRole is null)
|
||||||
//if it doesn't exist, create it
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false);
|
muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//if creations fails, maybe the name is not correct, find default one, if doesn't work, create default one
|
Log.Warning(ex, "Unable to create mute role for guild {GuildId}", guild.Id);
|
||||||
muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName)
|
return null;
|
||||||
?? await guild.CreateRoleAsync(defaultMuteRoleName, isMentionable: false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,9 +279,10 @@ public class MuteService : IEService, IReadyExecutor
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions)
|
||||||
{
|
{
|
||||||
// ignored
|
Log.Error(ex, "Error in Initializing mute role in guild {GuildId}: {Message}", guild.Id, ex.Message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace EllieBot.Modules.Administration.Services;
|
||||||
|
|
||||||
public class ProtectionService : IReadyExecutor, IEService
|
public class ProtectionService : IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
public event Func<PunishmentAction, ProtectionType, IGuildUser[], Task> OnAntiProtectionTriggered = delegate
|
public event Func<PunishmentAction, ProtectionType, IGuildUser[], Task> OnAntiProtectionTriggered = static delegate
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
@ -301,7 +301,7 @@ public class ProtectionService : IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
if (_antiRaidGuilds.TryRemove(guildId, out _))
|
if (_antiRaidGuilds.TryRemove(guildId, out _))
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
await uow.GetTable<AntiRaidSetting>()
|
await uow.GetTable<AntiRaidSetting>()
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.DeleteAsync();
|
.DeleteAsync();
|
||||||
|
@ -316,7 +316,7 @@ public class ProtectionService : IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
if (_antiSpamGuilds.TryRemove(guildId, out _))
|
if (_antiSpamGuilds.TryRemove(guildId, out _))
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
await uow.GetTable<AntiSpamSetting>()
|
await uow.GetTable<AntiSpamSetting>()
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.DeleteAsync();
|
.DeleteAsync();
|
||||||
|
@ -335,6 +335,8 @@ public class ProtectionService : IReadyExecutor, IEService
|
||||||
ulong? roleId)
|
ulong? roleId)
|
||||||
{
|
{
|
||||||
var g = _client.GetGuild(guildId);
|
var g = _client.GetGuild(guildId);
|
||||||
|
|
||||||
|
if (action == PunishmentAction.Mute)
|
||||||
await _mute.GetMuteRole(g);
|
await _mute.GetMuteRole(g);
|
||||||
|
|
||||||
if (!IsDurationAllowed(action))
|
if (!IsDurationAllowed(action))
|
||||||
|
@ -391,7 +393,7 @@ public class ProtectionService : IReadyExecutor, IEService
|
||||||
};
|
};
|
||||||
|
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
var spam = await uow.GetTable<AntiSpamSetting>()
|
var spam = await uow.Set<AntiSpamSetting>()
|
||||||
.Include(x => x.IgnoredChannels)
|
.Include(x => x.IgnoredChannels)
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.FirstOrDefaultAsyncEF();
|
.FirstOrDefaultAsyncEF();
|
||||||
|
|
|
@ -22,15 +22,17 @@ public partial class Utility
|
||||||
var eb = CreateEmbed()
|
var eb = CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithDescription(GetText(strs.livechannel_added(channel.Name)))
|
.WithDescription(GetText(strs.livechannel_added(channel.Name)))
|
||||||
.AddField(GetText(strs.template), template)
|
.AddField(GetText(strs.template), template, true)
|
||||||
.AddField(GetText(strs.preview),
|
.AddField(GetText(strs.preview),
|
||||||
await repSvc.ReplaceAsync(template,
|
await repSvc.ReplaceAsync(template,
|
||||||
new(
|
new(
|
||||||
client: ctx.Client as DiscordSocketClient,
|
client: ctx.Client as DiscordSocketClient,
|
||||||
guild: ctx.Guild
|
guild: ctx.Guild
|
||||||
)));
|
)),
|
||||||
|
true)
|
||||||
|
.WithFooter(GetText(strs.livechannel_please_wait));
|
||||||
await Response()
|
await Response()
|
||||||
.Confirm(strs.livechannel_added(channel.Name))
|
.Embed(eb)
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,9 @@ public class LiveChannelService(
|
||||||
if (channel.Name != text)
|
if (channel.Name != text)
|
||||||
await channel.ModifyAsync(x => x.Name = text);
|
await channel.ModifyAsync(x => x.Name = text);
|
||||||
}
|
}
|
||||||
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden)
|
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden
|
||||||
|
|| ex.DiscordCode == DiscordErrorCode.MissingPermissions
|
||||||
|
|| ex.HttpCode == HttpStatusCode.NotFound)
|
||||||
{
|
{
|
||||||
await RemoveLiveChannelAsync(config.GuildId, config.ChannelId);
|
await RemoveLiveChannelAsync(config.GuildId, config.ChannelId);
|
||||||
Log.Warning(
|
Log.Warning(
|
||||||
|
|
|
@ -1230,6 +1230,7 @@
|
||||||
"livechannel_not_found": "Channel was not found in the live channels list.",
|
"livechannel_not_found": "Channel was not found in the live channels list.",
|
||||||
"livechannel_list_title": "Live Channels in {0}",
|
"livechannel_list_title": "Live Channels in {0}",
|
||||||
"livechannel_list_empty": "No live channels configured for this server.",
|
"livechannel_list_empty": "No live channels configured for this server.",
|
||||||
|
"livechannel_please_wait": "Please allow up to 10 minutes for the changes to take effect",
|
||||||
"template": "Template",
|
"template": "Template",
|
||||||
"preview": "Preview"
|
"preview": "Preview"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue