;gmod, ;cmd, ;lgp and .resetglobalperms added. Bot owner can disable modules or commands bot-wide.
This commit is contained in:
parent
a89d00ff31
commit
98c330d6a6
1553
src/NadekoBot/Migrations/20170409193757_gmod-and-cmod.Designer.cs
generated
Normal file
1553
src/NadekoBot/Migrations/20170409193757_gmod-and-cmod.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
56
src/NadekoBot/Migrations/20170409193757_gmod-and-cmod.cs
Normal file
56
src/NadekoBot/Migrations/20170409193757_gmod-and-cmod.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class gmodandcmod : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BlockedCmdOrMdl",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
BotConfigId = table.Column<int>(nullable: true),
|
||||
BotConfigId1 = table.Column<int>(nullable: true),
|
||||
DateAdded = table.Column<DateTime>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BlockedCmdOrMdl", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_BlockedCmdOrMdl_BotConfig_BotConfigId",
|
||||
column: x => x.BotConfigId,
|
||||
principalTable: "BotConfig",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_BlockedCmdOrMdl_BotConfig_BotConfigId1",
|
||||
column: x => x.BotConfigId1,
|
||||
principalTable: "BotConfig",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BlockedCmdOrMdl_BotConfigId",
|
||||
table: "BlockedCmdOrMdl",
|
||||
column: "BotConfigId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BlockedCmdOrMdl_BotConfigId1",
|
||||
table: "BlockedCmdOrMdl",
|
||||
column: "BotConfigId1");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BlockedCmdOrMdl");
|
||||
}
|
||||
}
|
||||
}
|
@ -99,6 +99,28 @@ namespace NadekoBot.Migrations
|
||||
b.ToTable("BlacklistItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlockedCmdOrMdl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int?>("BotConfigId");
|
||||
|
||||
b.Property<int?>("BotConfigId1");
|
||||
|
||||
b.Property<DateTime?>("DateAdded");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BotConfigId");
|
||||
|
||||
b.HasIndex("BotConfigId1");
|
||||
|
||||
b.ToTable("BlockedCmdOrMdl");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -1277,6 +1299,17 @@ namespace NadekoBot.Migrations
|
||||
.HasForeignKey("BotConfigId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlockedCmdOrMdl", b =>
|
||||
{
|
||||
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
|
||||
.WithMany("BlockedCommands")
|
||||
.HasForeignKey("BotConfigId");
|
||||
|
||||
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
|
||||
.WithMany("BlockedModules")
|
||||
.HasForeignKey("BotConfigId1");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b =>
|
||||
{
|
||||
b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar")
|
||||
|
@ -67,6 +67,23 @@ namespace NadekoBot.Modules.Administration
|
||||
await ReplyConfirmLocalized("perms_reset").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task ResetGlobalPermissions()
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var gc = uow.BotConfig.GetOrCreate();
|
||||
gc.BlockedCommands.Clear();
|
||||
gc.BlockedModules.Clear();
|
||||
|
||||
GlobalPermissionCommands.BlockedCommands.Clear();
|
||||
GlobalPermissionCommands.BlockedModules.Clear();
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
await ReplyConfirmLocalized("global_perms_reset").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.Administrator)]
|
||||
|
@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[Group]
|
||||
public class GameChannelCommands : NadekoSubmodule
|
||||
{
|
||||
private static readonly Timer _t;
|
||||
//private static readonly Timer _t;
|
||||
|
||||
private static readonly ConcurrentHashSet<ulong> gameVoiceChannels = new ConcurrentHashSet<ulong>();
|
||||
|
||||
|
@ -0,0 +1,118 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.DataStructures;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Services.Database;
|
||||
using NadekoBot.TypeReaders;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions
|
||||
{
|
||||
public partial class Permissions
|
||||
{
|
||||
[Group]
|
||||
public class GlobalPermissionCommands : NadekoSubmodule
|
||||
{
|
||||
public static readonly ConcurrentHashSet<string> BlockedModules;
|
||||
public static readonly ConcurrentHashSet<string> BlockedCommands;
|
||||
|
||||
static GlobalPermissionCommands()
|
||||
{
|
||||
BlockedModules = new ConcurrentHashSet<string>(NadekoBot.BotConfig.BlockedModules.Select(x => x.Name));
|
||||
BlockedCommands = new ConcurrentHashSet<string>(NadekoBot.BotConfig.BlockedCommands.Select(x => x.Name));
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task Lgp()
|
||||
{
|
||||
if (!BlockedModules.Any() && !BlockedCommands.Any())
|
||||
{
|
||||
await ReplyErrorLocalized("lgp_none").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
|
||||
if (BlockedModules.Any())
|
||||
embed.AddField(efb => efb.WithName(GetText("blocked_modules")).WithValue(string.Join("\n", BlockedModules)).WithIsInline(false));
|
||||
|
||||
if (BlockedCommands.Any())
|
||||
embed.AddField(efb => efb.WithName(GetText("blocked_commands")).WithValue(string.Join("\n", BlockedCommands)).WithIsInline(false));
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task Gmod(ModuleInfo module)
|
||||
{
|
||||
var moduleName = module.Name.ToLowerInvariant();
|
||||
if (BlockedModules.Add(moduleName))
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var bc = uow.BotConfig.GetOrCreate();
|
||||
bc.BlockedModules.Add(new Services.Database.Models.BlockedCmdOrMdl
|
||||
{
|
||||
Name = moduleName,
|
||||
});
|
||||
uow.Complete();
|
||||
}
|
||||
await ReplyConfirmLocalized("gmod_add", Format.Bold(module.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else if (BlockedModules.TryRemove(moduleName))
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var bc = uow.BotConfig.GetOrCreate();
|
||||
bc.BlockedModules.RemoveWhere(x => x.Name == moduleName);
|
||||
uow.Complete();
|
||||
}
|
||||
await ReplyConfirmLocalized("gmod_remove", Format.Bold(module.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task Gcmd(CommandOrCrInfo cmd)
|
||||
{
|
||||
var commandName = cmd.Name.ToLowerInvariant();
|
||||
if (BlockedCommands.Add(commandName))
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var bc = uow.BotConfig.GetOrCreate();
|
||||
bc.BlockedCommands.Add(new Services.Database.Models.BlockedCmdOrMdl
|
||||
{
|
||||
Name = commandName,
|
||||
});
|
||||
uow.Complete();
|
||||
}
|
||||
await ReplyConfirmLocalized("gcmd_add", Format.Bold(cmd.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else if (BlockedCommands.TryRemove(commandName))
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var bc = uow.BotConfig.GetOrCreate();
|
||||
bc.BlockedCommands.RemoveWhere(x => x.Name == commandName);
|
||||
uow.Complete();
|
||||
}
|
||||
await ReplyConfirmLocalized("gcmd_remove", Format.Bold(cmd.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
public partial class Utility
|
||||
{
|
||||
|
||||
public class CommandAliasEqualityComparer : IEqualityComparer<CommandAlias>
|
||||
{
|
||||
public bool Equals(CommandAlias x, CommandAlias y) => x.Trigger == y.Trigger;
|
||||
@ -41,6 +40,11 @@ namespace NadekoBot.Modules.Utility
|
||||
.ToDictionary(ca => ca.Trigger, ca => ca.Mapping))));
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
AliasMaps.Clear();
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireUserPermission(GuildPermission.Administrator)]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@ -3,6 +3,7 @@ using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -16,43 +17,50 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
static CrossServerTextChannel()
|
||||
{
|
||||
NadekoBot.Client.MessageReceived += async imsg =>
|
||||
NadekoBot.Client.MessageReceived += Client_MessageReceived;
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
NadekoBot.Client.MessageReceived -= Client_MessageReceived;
|
||||
}
|
||||
|
||||
private static async Task Client_MessageReceived(Discord.WebSocket.SocketMessage imsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
if (imsg.Author.IsBot)
|
||||
return;
|
||||
var msg = imsg as IUserMessage;
|
||||
if (msg == null)
|
||||
return;
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
if (channel == null)
|
||||
return;
|
||||
if (msg.Author.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||
foreach (var subscriber in Subscribers)
|
||||
{
|
||||
if (imsg.Author.IsBot)
|
||||
return;
|
||||
var msg = imsg as IUserMessage;
|
||||
if (msg == null)
|
||||
return;
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
if (channel == null)
|
||||
return;
|
||||
if (msg.Author.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||
foreach (var subscriber in Subscribers)
|
||||
var set = subscriber.Value;
|
||||
if (!set.Contains(channel))
|
||||
continue;
|
||||
foreach (var chan in set.Except(new[] { channel }))
|
||||
{
|
||||
var set = subscriber.Value;
|
||||
if (!set.Contains(channel))
|
||||
continue;
|
||||
foreach (var chan in set.Except(new[] {channel}))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
await chan.SendMessageAsync(GetMessage(channel, (IGuildUser) msg.Author,
|
||||
msg)).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
await chan.SendMessageAsync(GetMessage(channel, (IGuildUser)msg.Author,
|
||||
msg)).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetMessage(ITextChannel channel, IGuildUser user, IUserMessage message) =>
|
||||
|
@ -48,7 +48,6 @@ namespace NadekoBot.Modules.Utility
|
||||
Task.Run(Run);
|
||||
}
|
||||
|
||||
|
||||
private async Task Run()
|
||||
{
|
||||
source = new CancellationTokenSource();
|
||||
@ -124,7 +123,12 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
#if !GLOBAL_NADEKO
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
#else
|
||||
await Task.Delay(30000).ConfigureAwait(false);
|
||||
#endif
|
||||
//todo this is pretty terrible
|
||||
Repeaters = new ConcurrentDictionary<ulong, ConcurrentQueue<RepeatRunner>>(NadekoBot.AllGuildConfigs
|
||||
.ToDictionary(gc => gc.GuildId,
|
||||
gc => new ConcurrentQueue<RepeatRunner>(gc.GuildRepeaters
|
||||
@ -134,6 +138,21 @@ namespace NadekoBot.Modules.Utility
|
||||
});
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
_ready = false;
|
||||
foreach (var kvp in Repeaters)
|
||||
{
|
||||
RepeatRunner r;
|
||||
while (kvp.Value.TryDequeue(out r))
|
||||
{
|
||||
r.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Repeaters.Clear();
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.ManageMessages)]
|
||||
|
@ -29,6 +29,11 @@ namespace NadekoBot.Modules.Utility
|
||||
patreon = PatreonThingy.Instance;
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
patreon.Updater.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task PatreonRewardsReload()
|
||||
@ -86,7 +91,7 @@ namespace NadekoBot.Modules.Utility
|
||||
public ImmutableArray<PatreonUserAndReward> Pledges { get; private set; }
|
||||
public DateTime LastUpdate { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
private readonly Timer update;
|
||||
public readonly Timer Updater;
|
||||
private readonly SemaphoreSlim claimLockJustInCase = new SemaphoreSlim(1, 1);
|
||||
private readonly Logger _log;
|
||||
|
||||
@ -97,7 +102,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.PatreonAccessToken))
|
||||
return;
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
update = new Timer(async (_) => await LoadPledges(), null, TimeSpan.Zero, Interval);
|
||||
Updater = new Timer(async (_) => await LoadPledges(), null, TimeSpan.Zero, Interval);
|
||||
}
|
||||
|
||||
public async Task LoadPledges()
|
||||
|
@ -32,10 +32,15 @@ namespace NadekoBot.Modules.Utility
|
||||
};
|
||||
|
||||
private new static readonly Logger _log;
|
||||
private static readonly CancellationTokenSource cancelSource;
|
||||
private static readonly CancellationToken cancelAllToken;
|
||||
|
||||
static RemindCommands()
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
cancelSource = new CancellationTokenSource();
|
||||
cancelAllToken = cancelSource.Token;
|
||||
List<Reminder> reminders;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
@ -45,11 +50,17 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
foreach (var r in reminders)
|
||||
{
|
||||
Task.Run(() => StartReminder(r));
|
||||
Task.Run(() => StartReminder(r, cancelAllToken));
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task StartReminder(Reminder r)
|
||||
public static void Unload()
|
||||
{
|
||||
if (!cancelSource.IsCancellationRequested)
|
||||
cancelSource.Cancel();
|
||||
}
|
||||
|
||||
private static async Task StartReminder(Reminder r, CancellationToken t)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
@ -58,7 +69,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (time.TotalMilliseconds > int.MaxValue)
|
||||
return;
|
||||
|
||||
await Task.Delay(time).ConfigureAwait(false);
|
||||
await Task.Delay(time, t).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
IMessageChannel ch;
|
||||
@ -188,7 +199,7 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
await StartReminder(rem);
|
||||
await StartReminder(rem, cancelAllToken);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
|
@ -49,14 +49,19 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
Units = data.ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Warn("Could not load units: " + e.Message);
|
||||
_log.Warn("Could not load units: " + ex.Message);
|
||||
}
|
||||
|
||||
_timer = new Timer(async (obj) => await UpdateCurrency(), null, _updateInterval, _updateInterval);
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
_timer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
||||
public static async Task UpdateCurrency()
|
||||
{
|
||||
try
|
||||
|
@ -25,6 +25,12 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
private static ConcurrentDictionary<ulong, Timer> _rotatingRoleColors = new ConcurrentDictionary<ulong, Timer>();
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
_rotatingRoleColors.ForEach(x => x.Value?.Change(Timeout.Infinite, Timeout.Infinite));
|
||||
_rotatingRoleColors.Clear();
|
||||
}
|
||||
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Midorina([Remainder] string arg)
|
||||
@ -49,7 +55,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
// var roleStrings = roles
|
||||
// .Select(x => $"{reactions[j++]} -> {x.Name}");
|
||||
|
||||
|
||||
// var msg = await Context.Channel.SendConfirmAsync("Pick a Role",
|
||||
// string.Join("\n", roleStrings)).ConfigureAwait(false);
|
||||
|
||||
@ -100,6 +106,7 @@ namespace NadekoBot.Modules.Utility
|
||||
// }
|
||||
// }));
|
||||
//}
|
||||
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
110
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
110
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -3012,7 +3012,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game if it exists. Can't move users to channels that the bot has no connect permission for. One per server..
|
||||
/// Looks up a localized string similar to Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game, if it exists. Can't move users to channels that the bot has no connect permission for. One per server..
|
||||
/// </summary>
|
||||
public static string gamevoicechannel_desc {
|
||||
get {
|
||||
@ -3029,6 +3029,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to globalcommand gcmd.
|
||||
/// </summary>
|
||||
public static string gcmd_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("gcmd_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enables or disables a command from use on all servers..
|
||||
/// </summary>
|
||||
public static string gcmd_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("gcmd_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}gcmd `.
|
||||
/// </summary>
|
||||
public static string gcmd_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("gcmd_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to gelbooru.
|
||||
/// </summary>
|
||||
@ -3110,6 +3137,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to globalmodule gmod.
|
||||
/// </summary>
|
||||
public static string gmod_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("gmod_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enable or disable a module from use on all servers..
|
||||
/// </summary>
|
||||
public static string gmod_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("gmod_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}gmod nsfw disable`.
|
||||
/// </summary>
|
||||
public static string gmod_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("gmod_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to google g.
|
||||
/// </summary>
|
||||
@ -4055,6 +4109,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to listglobalperms lgp.
|
||||
/// </summary>
|
||||
public static string lgp_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("lgp_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Lists global permissions set by the bot owner..
|
||||
/// </summary>
|
||||
public static string lgp_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("lgp_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}lgp`.
|
||||
/// </summary>
|
||||
public static string lgp_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("lgp_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to linux.
|
||||
/// </summary>
|
||||
@ -6512,6 +6593,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to resetglobalperms.
|
||||
/// </summary>
|
||||
public static string resetglobalpermissions_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("resetglobalpermissions_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Resets global permissions set by bot owner..
|
||||
/// </summary>
|
||||
public static string resetglobalpermissions_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("resetglobalpermissions_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}resetglobalperms`.
|
||||
/// </summary>
|
||||
public static string resetglobalpermissions_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("resetglobalpermissions_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to resetperms.
|
||||
/// </summary>
|
||||
|
@ -3421,7 +3421,7 @@
|
||||
<value>gvc</value>
|
||||
</data>
|
||||
<data name="gamevoicechannel_desc" xml:space="preserve">
|
||||
<value>Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game if it exists. Can't move users to channels that the bot has no connect permission for. One per server.</value>
|
||||
<value>Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game, if it exists. Can't move users to channels that the bot has no connect permission for. One per server.</value>
|
||||
</data>
|
||||
<data name="gamevoicechannel_usage" xml:space="preserve">
|
||||
<value>`{0}gvc`</value>
|
||||
@ -3438,4 +3438,40 @@
|
||||
<data name="shopremove_usage" xml:space="preserve">
|
||||
<value>`{0}shoprm 1`</value>
|
||||
</data>
|
||||
<data name="gcmd_cmd" xml:space="preserve">
|
||||
<value>globalcommand gcmd</value>
|
||||
</data>
|
||||
<data name="gcmd_desc" xml:space="preserve">
|
||||
<value>Enables or disables a command from use on all servers.</value>
|
||||
</data>
|
||||
<data name="gcmd_usage" xml:space="preserve">
|
||||
<value>`{0}gcmd `</value>
|
||||
</data>
|
||||
<data name="gmod_cmd" xml:space="preserve">
|
||||
<value>globalmodule gmod</value>
|
||||
</data>
|
||||
<data name="gmod_desc" xml:space="preserve">
|
||||
<value>Enable or disable a module from use on all servers.</value>
|
||||
</data>
|
||||
<data name="gmod_usage" xml:space="preserve">
|
||||
<value>`{0}gmod nsfw disable`</value>
|
||||
</data>
|
||||
<data name="lgp_cmd" xml:space="preserve">
|
||||
<value>listglobalperms lgp</value>
|
||||
</data>
|
||||
<data name="lgp_desc" xml:space="preserve">
|
||||
<value>Lists global permissions set by the bot owner.</value>
|
||||
</data>
|
||||
<data name="lgp_usage" xml:space="preserve">
|
||||
<value>`{0}lgp`</value>
|
||||
</data>
|
||||
<data name="resetglobalpermissions_cmd" xml:space="preserve">
|
||||
<value>resetglobalperms</value>
|
||||
</data>
|
||||
<data name="resetglobalpermissions_desc" xml:space="preserve">
|
||||
<value>Resets global permissions set by bot owner.</value>
|
||||
</data>
|
||||
<data name="resetglobalpermissions_usage" xml:space="preserve">
|
||||
<value>`{0}resetglobalperms`</value>
|
||||
</data>
|
||||
</root>
|
72
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
72
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -411,6 +411,15 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Global permissions have been reset..
|
||||
/// </summary>
|
||||
public static string administration_global_perms_reset {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_global_perms_reset", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Greet announcements disabled..
|
||||
/// </summary>
|
||||
@ -4711,6 +4720,24 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Blocked Commands.
|
||||
/// </summary>
|
||||
public static string permissions_blocked_commands {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_blocked_commands", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Blocked Modules.
|
||||
/// </summary>
|
||||
public static string permissions_blocked_modules {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_blocked_modules", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Command {0} now has a {1}s cooldown..
|
||||
/// </summary>
|
||||
@ -4801,6 +4828,42 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Command {0} has been disabled on all servers..
|
||||
/// </summary>
|
||||
public static string permissions_gcmd_add {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_gcmd_add", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Command {0} has been enabled on all servers..
|
||||
/// </summary>
|
||||
public static string permissions_gcmd_remove {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_gcmd_remove", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Module {0} has been disabled on all servers..
|
||||
/// </summary>
|
||||
public static string permissions_gmod_add {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_gmod_add", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Module {0} has been enabled on all servers..
|
||||
/// </summary>
|
||||
public static string permissions_gmod_remove {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_gmod_remove", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid second parameter.(Must be a number between {0} and {1}).
|
||||
/// </summary>
|
||||
@ -4846,6 +4909,15 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No blocked commands or modules..
|
||||
/// </summary>
|
||||
public static string permissions_lgp_none {
|
||||
get {
|
||||
return ResourceManager.GetString("permissions_lgp_none", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Moved permission {0} from #{1} to #{2}.
|
||||
/// </summary>
|
||||
|
@ -2431,6 +2431,9 @@ Owner ID: {2}</value>
|
||||
<value>Next update in {0}</value>
|
||||
<comment>Next update in 05:30</comment>
|
||||
</data>
|
||||
<data name="administration_global_perms_reset" xml:space="preserve">
|
||||
<value>Global permissions have been reset.</value>
|
||||
</data>
|
||||
<data name="administration_gvc_disabled" xml:space="preserve">
|
||||
<value>Game Voice Channel feature has been disabled on this server.</value>
|
||||
</data>
|
||||
@ -2485,4 +2488,25 @@ Owner ID: {2}</value>
|
||||
<data name="gambling_unique_items_left" xml:space="preserve">
|
||||
<value>{0} unique items left.</value>
|
||||
</data>
|
||||
<data name="permissions_blocked_commands" xml:space="preserve">
|
||||
<value>Blocked Commands</value>
|
||||
</data>
|
||||
<data name="permissions_blocked_modules" xml:space="preserve">
|
||||
<value>Blocked Modules</value>
|
||||
</data>
|
||||
<data name="permissions_gcmd_add" xml:space="preserve">
|
||||
<value>Command {0} has been disabled on all servers.</value>
|
||||
</data>
|
||||
<data name="permissions_gcmd_remove" xml:space="preserve">
|
||||
<value>Command {0} has been enabled on all servers.</value>
|
||||
</data>
|
||||
<data name="permissions_gmod_add" xml:space="preserve">
|
||||
<value>Module {0} has been disabled on all servers.</value>
|
||||
</data>
|
||||
<data name="permissions_gmod_remove" xml:space="preserve">
|
||||
<value>Module {0} has been enabled on all servers.</value>
|
||||
</data>
|
||||
<data name="permissions_lgp_none" xml:space="preserve">
|
||||
<value>No blocked commands or modules.</value>
|
||||
</data>
|
||||
</root>
|
@ -486,15 +486,22 @@ namespace NadekoBot.Services
|
||||
}
|
||||
}
|
||||
|
||||
int price;
|
||||
if (Permissions.CommandCostCommands.CommandCosts.TryGetValue(cmd.Aliases.First().Trim().ToLowerInvariant(), out price) && price > 0)
|
||||
{
|
||||
var success = await CurrencyHandler.RemoveCurrencyAsync(context.User.Id, $"Running {cmd.Name} command.", price).ConfigureAwait(false);
|
||||
if (!success)
|
||||
{
|
||||
return new ExecuteCommandResult(cmd, pc, SearchResult.FromError(CommandError.Exception, $"Insufficient funds. You need {price}{NadekoBot.BotConfig.CurrencySign} to run this command."));
|
||||
}
|
||||
}
|
||||
//int price;
|
||||
//if (Permissions.CommandCostCommands.CommandCosts.TryGetValue(cmd.Aliases.First().Trim().ToLowerInvariant(), out price) && price > 0)
|
||||
//{
|
||||
// var success = await CurrencyHandler.RemoveCurrencyAsync(context.User.Id, $"Running {cmd.Name} command.", price).ConfigureAwait(false);
|
||||
// if (!success)
|
||||
// {
|
||||
// return new ExecuteCommandResult(cmd, pc, SearchResult.FromError(CommandError.Exception, $"Insufficient funds. You need {price}{NadekoBot.BotConfig.CurrencySign} to run this command."));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
if (cmd.Name != "resetglobalperms" &&
|
||||
(GlobalPermissionCommands.BlockedCommands.Contains(cmd.Aliases.First().ToLowerInvariant()) ||
|
||||
GlobalPermissionCommands.BlockedModules.Contains(module.Name.ToLowerInvariant())))
|
||||
{
|
||||
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"Command or module is blocked globally by the bot owner."));
|
||||
}
|
||||
|
||||
// Bot will ignore commands which are ran more often than what specified by
|
||||
|
@ -62,6 +62,25 @@ Nadeko Support Server: https://discord.gg/nadekobot";
|
||||
public string ErrorColor { get; set; } = "ee281f";
|
||||
public string Locale { get; set; } = null;
|
||||
public List<StartupCommand> StartupCommands { get; set; }
|
||||
public HashSet<BlockedCmdOrMdl> BlockedCommands { get; set; }
|
||||
public HashSet<BlockedCmdOrMdl> BlockedModules { get; set; }
|
||||
}
|
||||
|
||||
public class BlockedCmdOrMdl : DbEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((BlockedCmdOrMdl)obj).Name.ToLowerInvariant() == Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
}
|
||||
|
||||
public class StartupCommand : DbEntity, IIndexed
|
||||
|
@ -22,6 +22,8 @@ namespace NadekoBot.Services.Database.Repositories.Impl
|
||||
.Include(bc => bc.EightBallResponses)
|
||||
.Include(bc => bc.ModulePrefixes)
|
||||
.Include(bc => bc.StartupCommands)
|
||||
.Include(bc => bc.BlockedCommands)
|
||||
.Include(bc => bc.BlockedModules)
|
||||
//.Include(bc => bc.CommandCosts)
|
||||
.FirstOrDefault();
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user