Blacklisting done
This commit is contained in:
parent
4459c19e70
commit
8f2b48c291
@ -24,6 +24,8 @@ namespace NadekoBot.Migrations
|
|||||||
|
|
||||||
b.Property<ulong>("ItemId");
|
b.Property<ulong>("ItemId");
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("BotConfigId");
|
b.HasIndex("BotConfigId");
|
||||||
|
@ -197,13 +197,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
await channel.SendMessageAsync(
|
await channel.SendMessageAsync(
|
||||||
richest.Aggregate(new StringBuilder(
|
richest.Aggregate(new StringBuilder(
|
||||||
$@"```xl
|
$@"```xl
|
||||||
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
|
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
|
||||||
┃ Id ┃ $$$ ┃
|
┃ Id ┃ $$$ ┃
|
||||||
"),
|
"),
|
||||||
(cur, cs) => cur.AppendLine(
|
(cur, cs) => cur.AppendLine($@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
|
||||||
$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫
|
┃{(channel.Guild.GetUser(cs.UserId)?.Username.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Amount,6} ┃")
|
||||||
┃{(channel.Guild.GetUser(cs.UserId)?.Username.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs,5} ┃")
|
).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━┛```").ConfigureAwait(false);
|
||||||
).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ namespace NadekoBot.Modules.Games.Trivia
|
|||||||
{
|
{
|
||||||
private readonly SemaphoreSlim _guessLock = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _guessLock = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
private IGuild guild { get; }
|
public IGuild guild { get; }
|
||||||
private ITextChannel channel { get; }
|
public ITextChannel channel { get; }
|
||||||
|
|
||||||
private int QuestionDurationMiliseconds { get; } = 30000;
|
private int QuestionDurationMiliseconds { get; } = 30000;
|
||||||
private int HintTimeoutMiliseconds { get; } = 6000;
|
private int HintTimeoutMiliseconds { get; } = 6000;
|
||||||
|
@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permIndex = i + 1;
|
permIndex = i;
|
||||||
return result.Value;
|
return result.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ using Discord.API;
|
|||||||
namespace NadekoBot.Modules.Permissions
|
namespace NadekoBot.Modules.Permissions
|
||||||
{
|
{
|
||||||
[NadekoModule("Permissions", ";")]
|
[NadekoModule("Permissions", ";")]
|
||||||
public class Permissions : DiscordModule
|
public partial class Permissions : DiscordModule
|
||||||
{
|
{
|
||||||
public Permissions(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client)
|
public Permissions(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
public async Task UserId(IUserMessage msg, IGuildUser target = null)
|
public async Task UserId(IUserMessage msg, IGuildUser target = null)
|
||||||
{
|
{
|
||||||
var usr = target ?? msg.Author;
|
var usr = target ?? msg.Author;
|
||||||
await msg.Reply($"Id of the user { usr.Username } is { usr.Id })").ConfigureAwait(false);
|
await msg.Reply($"Id of the user { usr.Username } is { usr.Id }").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||||
|
122
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
122
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -1061,27 +1061,27 @@ namespace NadekoBot.Resources {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Blacklists a mentioned channel (#general for example)..
|
/// Looks up a localized string similar to Blacklists a mentioned channel (#general for example)..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string cbl_desc {
|
public static string channelblacklist_desc {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("cbl_desc", resourceCulture);
|
return ResourceManager.GetString("channelblacklist_desc", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to `;cbl #some_channel`.
|
/// Looks up a localized string similar to `;cbl #some_channel`.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string cbl_summary {
|
public static string channelblacklist_summary {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("cbl_summary", resourceCulture);
|
return ResourceManager.GetString("channelblacklist_summary", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to cbl.
|
/// Looks up a localized string similar to cbl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string cbl_text {
|
public static string channelblacklist_text {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("cbl_text", resourceCulture);
|
return ResourceManager.GetString("channelblacklist_text", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,7 +1104,7 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to channelid.
|
/// Looks up a localized string similar to channelid cid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string channelid_text {
|
public static string channelid_text {
|
||||||
get {
|
get {
|
||||||
@ -5972,33 +5972,6 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Blacklists a server by a name or id (#general for example). **BOT OWNER ONLY**.
|
|
||||||
/// </summary>
|
|
||||||
public static string sbl_desc {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("sbl_desc", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to `;sbl [servername/serverid]`.
|
|
||||||
/// </summary>
|
|
||||||
public static string sbl_summary {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("sbl_summary", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to sbl.
|
|
||||||
/// </summary>
|
|
||||||
public static string sbl_text {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("sbl_text", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Starts an instance of cross server channel. You will get a token as a DM that other people will use to tune in to the same instance. **Bot Owner Only.**.
|
/// Looks up a localized string similar to Starts an instance of cross server channel. You will get a token as a DM that other people will use to tune in to the same instance. **Bot Owner Only.**.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -6053,6 +6026,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Blacklists a server by a name or id (#general for example). **BOT OWNER ONLY**.
|
||||||
|
/// </summary>
|
||||||
|
public static string serverblacklist_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("serverblacklist_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `;sbl [servername/serverid]`.
|
||||||
|
/// </summary>
|
||||||
|
public static string serverblacklist_summary {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("serverblacklist_summary", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to sbl.
|
||||||
|
/// </summary>
|
||||||
|
public static string serverblacklist_text {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("serverblacklist_text", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Shows current server ID..
|
/// Looks up a localized string similar to Shows current server ID..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -7052,33 +7052,6 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Blacklists a mentioned user. **Bot Owner Only!**.
|
|
||||||
/// </summary>
|
|
||||||
public static string ubl_desc {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("ubl_desc", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to `;ubl [user_mention]`.
|
|
||||||
/// </summary>
|
|
||||||
public static string ubl_summary {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("ubl_summary", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to ubl.
|
|
||||||
/// </summary>
|
|
||||||
public static string ubl_text {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("ubl_text", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Unbinds a bot from the channel and board. **Bot Owner Only!**.
|
/// Looks up a localized string similar to Unbinds a bot from the channel and board. **Bot Owner Only!**.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -7241,6 +7214,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Blacklists a mentioned user. **Bot Owner Only!**.
|
||||||
|
/// </summary>
|
||||||
|
public static string userblacklist_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("userblacklist_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `;ubl [user_mention]`.
|
||||||
|
/// </summary>
|
||||||
|
public static string userblacklist_summary {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("userblacklist_summary", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ubl.
|
||||||
|
/// </summary>
|
||||||
|
public static string userblacklist_text {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("userblacklist_text", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Shows user ID..
|
/// Looks up a localized string similar to Shows user ID..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -919,7 +919,7 @@
|
|||||||
<value>`.uid` or `.uid "@SomeGuy"`</value>
|
<value>`.uid` or `.uid "@SomeGuy"`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="channelid_text" xml:space="preserve">
|
<data name="channelid_text" xml:space="preserve">
|
||||||
<value>channelid</value>
|
<value>channelid cid</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="channelid_desc" xml:space="preserve">
|
<data name="channelid_desc" xml:space="preserve">
|
||||||
<value>Shows current channel ID.</value>
|
<value>Shows current channel ID.</value>
|
||||||
@ -1224,13 +1224,13 @@
|
|||||||
<data name="allrolecmds_summary" xml:space="preserve">
|
<data name="allrolecmds_summary" xml:space="preserve">
|
||||||
<value>`;arc "module name" [enable/disable] MyRole`</value>
|
<value>`;arc "module name" [enable/disable] MyRole`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ubl_text" xml:space="preserve">
|
<data name="userblacklist_text" xml:space="preserve">
|
||||||
<value>ubl</value>
|
<value>ubl</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ubl_desc" xml:space="preserve">
|
<data name="userblacklist_desc" xml:space="preserve">
|
||||||
<value>Blacklists a mentioned user. **Bot Owner Only!**</value>
|
<value>Blacklists a mentioned user. **Bot Owner Only!**</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ubl_summary" xml:space="preserve">
|
<data name="userblacklist_summary" xml:space="preserve">
|
||||||
<value>`;ubl [user_mention]`</value>
|
<value>`;ubl [user_mention]`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="uubl_text" xml:space="preserve">
|
<data name="uubl_text" xml:space="preserve">
|
||||||
@ -1242,13 +1242,13 @@
|
|||||||
<data name="uubl_summary" xml:space="preserve">
|
<data name="uubl_summary" xml:space="preserve">
|
||||||
<value>`;uubl [user_mention]`</value>
|
<value>`;uubl [user_mention]`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cbl_text" xml:space="preserve">
|
<data name="channelblacklist_text" xml:space="preserve">
|
||||||
<value>cbl</value>
|
<value>cbl</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cbl_desc" xml:space="preserve">
|
<data name="channelblacklist_desc" xml:space="preserve">
|
||||||
<value>Blacklists a mentioned channel (#general for example).</value>
|
<value>Blacklists a mentioned channel (#general for example).</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cbl_summary" xml:space="preserve">
|
<data name="channelblacklist_summary" xml:space="preserve">
|
||||||
<value>`;cbl #some_channel`</value>
|
<value>`;cbl #some_channel`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cubl_text" xml:space="preserve">
|
<data name="cubl_text" xml:space="preserve">
|
||||||
@ -1260,13 +1260,13 @@
|
|||||||
<data name="cubl_summary" xml:space="preserve">
|
<data name="cubl_summary" xml:space="preserve">
|
||||||
<value>`;cubl #some_channel`</value>
|
<value>`;cubl #some_channel`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="sbl_text" xml:space="preserve">
|
<data name="serverblacklist_text" xml:space="preserve">
|
||||||
<value>sbl</value>
|
<value>sbl</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="sbl_desc" xml:space="preserve">
|
<data name="serverblacklist_desc" xml:space="preserve">
|
||||||
<value>Blacklists a server by a name or id (#general for example). **BOT OWNER ONLY**</value>
|
<value>Blacklists a server by a name or id (#general for example). **BOT OWNER ONLY**</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="sbl_summary" xml:space="preserve">
|
<data name="serverblacklist_summary" xml:space="preserve">
|
||||||
<value>`;sbl [servername/serverid]`</value>
|
<value>`;sbl [servername/serverid]`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cmdcooldown_text" xml:space="preserve">
|
<data name="cmdcooldown_text" xml:space="preserve">
|
||||||
|
@ -39,8 +39,21 @@ namespace NadekoBot.Services
|
|||||||
if (usrMsg == null)
|
if (usrMsg == null)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
|
if (usrMsg.Author.IsBot) //no bots
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var guild = (msg.Channel as ITextChannel)?.Guild;
|
var guild = (msg.Channel as ITextChannel)?.Guild;
|
||||||
|
|
||||||
|
BlacklistItem blacklistedItem;
|
||||||
|
if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi =>
|
||||||
|
(bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) ||
|
||||||
|
(bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) ||
|
||||||
|
(bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null)
|
||||||
|
{
|
||||||
|
_log.Warn("Attempt was made to run a command by a blacklisted {0}, id: {1}", blacklistedItem.Type, blacklistedItem.ItemId);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
var throwaway = Task.Run(async () =>
|
var throwaway = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var sw = new Stopwatch();
|
var sw = new Stopwatch();
|
||||||
@ -165,7 +178,7 @@ namespace NadekoBot.Services
|
|||||||
int index;
|
int index;
|
||||||
if (!rootPerm.AsEnumerable().CheckPermissions(message, cmd.Name, cmd.Module.Name, out index))
|
if (!rootPerm.AsEnumerable().CheckPermissions(message, cmd.Name, cmd.Module.Name, out index))
|
||||||
{
|
{
|
||||||
var returnMsg = $"Permission number #{index} **{rootPerm.GetAt(index).GetCommand()}** is preventing this action.";
|
var returnMsg = $"Permission number #{index + 1} **{rootPerm.GetAt(index).GetCommand()}** is preventing this action.";
|
||||||
return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, returnMsg));
|
return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, returnMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ namespace NadekoBot.Services.Database.Models
|
|||||||
public class BlacklistItem : DbEntity
|
public class BlacklistItem : DbEntity
|
||||||
{
|
{
|
||||||
public ulong ItemId { get; set; }
|
public ulong ItemId { get; set; }
|
||||||
|
public BlacklistType Type { get; set; }
|
||||||
|
|
||||||
public enum BlacklistType
|
public enum BlacklistType
|
||||||
{
|
{
|
||||||
Server,
|
Server,
|
||||||
|
Loading…
Reference in New Issue
Block a user