mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
fix: .verbose will now also be respected for expressions
This commit is contained in:
@@ -6,6 +6,7 @@ using NadekoBot.Db;
|
|||||||
using NadekoBot.Db.Models;
|
using NadekoBot.Db.Models;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
|
using NadekoBot.Modules.Permissions.Services;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
|
|
||||||
private bool ready;
|
private bool ready;
|
||||||
private ConcurrentHashSet<ulong> _disabledGlobalExpressionGuilds;
|
private ConcurrentHashSet<ulong> _disabledGlobalExpressionGuilds;
|
||||||
|
private readonly PermissionService _pc;
|
||||||
|
|
||||||
public NadekoExpressionsService(
|
public NadekoExpressionsService(
|
||||||
DbService db,
|
DbService db,
|
||||||
@@ -87,7 +89,8 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
IPubSub pubSub,
|
IPubSub pubSub,
|
||||||
IMessageSenderService sender,
|
IMessageSenderService sender,
|
||||||
IReplacementService repSvc,
|
IReplacementService repSvc,
|
||||||
IPermissionChecker permChecker)
|
IPermissionChecker permChecker,
|
||||||
|
PermissionService pc)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_client = client;
|
_client = client;
|
||||||
@@ -98,6 +101,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
_sender = sender;
|
_sender = sender;
|
||||||
_repSvc = repSvc;
|
_repSvc = repSvc;
|
||||||
_permChecker = permChecker;
|
_permChecker = permChecker;
|
||||||
|
_pc = pc;
|
||||||
_rng = new NadekoRandom();
|
_rng = new NadekoRandom();
|
||||||
|
|
||||||
_pubSub.Sub(_exprsReloadedKey, OnExprsShouldReload);
|
_pubSub.Sub(_exprsReloadedKey, OnExprsShouldReload);
|
||||||
@@ -138,6 +142,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
var globalItems = uow.Set<NadekoExpression>()
|
var globalItems = uow.Set<NadekoExpression>()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(x => x.GuildId == null || x.GuildId == 0)
|
.Where(x => x.GuildId == null || x.GuildId == 0)
|
||||||
|
.Where(x => x.Trigger != null)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
@@ -257,23 +262,27 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
|
|||||||
|
|
||||||
if (!result.IsAllowed)
|
if (!result.IsAllowed)
|
||||||
{
|
{
|
||||||
if (result.TryPickT3(out var disallowed, out _))
|
var cache = _pc.GetCacheFor(guild.Id);
|
||||||
|
if (cache.Verbose)
|
||||||
{
|
{
|
||||||
var permissionMessage = _strings.GetText(strs.perm_prevent(disallowed.PermIndex + 1,
|
if (result.TryPickT3(out var disallowed, out _))
|
||||||
Format.Bold(disallowed.PermText)),
|
|
||||||
sg.Id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await _sender.Response(msg.Channel)
|
var permissionMessage = _strings.GetText(strs.perm_prevent(disallowed.PermIndex + 1,
|
||||||
.Error(permissionMessage)
|
Format.Bold(disallowed.PermText)),
|
||||||
.SendAsync();
|
sg.Id);
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.Information("{PermissionMessage}", permissionMessage);
|
try
|
||||||
|
{
|
||||||
|
await _sender.Response(msg.Channel)
|
||||||
|
.Error(permissionMessage)
|
||||||
|
.SendAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Information("{PermissionMessage}", permissionMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user