cross server channels, logging when someone posts a link to console and incidents.txt
This commit is contained in:
parent
a21412715a
commit
a21a66f3c1
16
NadekoBot/Classes/IncidentsHandler.cs
Normal file
16
NadekoBot/Classes/IncidentsHandler.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NadekoBot.Classes {
|
||||||
|
class IncidentsHandler {
|
||||||
|
public static void Add(ulong serverId, string text) {
|
||||||
|
Directory.CreateDirectory("data/incidents");
|
||||||
|
File.AppendAllText($"data/incidents/{serverId}.txt", text + "\n--------------------------");
|
||||||
|
Console.WriteLine($"INCIDENT: {text}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,7 @@ using System;
|
|||||||
using Discord.Commands.Permissions;
|
using Discord.Commands.Permissions;
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Permissions {
|
namespace NadekoBot.Classes.Permissions {
|
||||||
public static class SimpleCheckers
|
public static class SimpleCheckers {
|
||||||
{
|
|
||||||
public static ManageRoles CanManageRoles { get; } = new ManageRoles();
|
public static ManageRoles CanManageRoles { get; } = new ManageRoles();
|
||||||
|
|
||||||
public static Func<Command, User, Channel, bool> OwnerOnly() =>
|
public static Func<Command, User, Channel, bool> OwnerOnly() =>
|
||||||
@ -17,8 +16,10 @@ namespace NadekoBot.Classes.Permissions {
|
|||||||
public static Func<Command, User, Channel, bool> ManageChannels() =>
|
public static Func<Command, User, Channel, bool> ManageChannels() =>
|
||||||
(com, user, ch) => user.ServerPermissions.ManageChannels;
|
(com, user, ch) => user.ServerPermissions.ManageChannels;
|
||||||
|
|
||||||
public class ManageRoles :IPermissionChecker
|
public static Func<Command, User, Channel, bool> ManageServer() =>
|
||||||
{
|
(com, user, ch) => user.ServerPermissions.ManageServer;
|
||||||
|
|
||||||
|
public class ManageRoles : IPermissionChecker {
|
||||||
public bool CanRun(Command command, User user, Channel channel, out string error) {
|
public bool CanRun(Command command, User user, Channel channel, out string error) {
|
||||||
error = string.Empty;
|
error = string.Empty;
|
||||||
if (user.ServerPermissions.ManageRoles)
|
if (user.ServerPermissions.ManageRoles)
|
||||||
|
@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes.Permissions;
|
using NadekoBot.Classes.Permissions;
|
||||||
using NadekoBot.Modules;
|
using NadekoBot.Modules;
|
||||||
using ServerPermissions = NadekoBot.Classes.Permissions.ServerPermissions;
|
using ServerPermissions = NadekoBot.Classes.Permissions.ServerPermissions;
|
||||||
@ -17,14 +18,19 @@ namespace NadekoBot.Commands {
|
|||||||
|
|
||||||
public FilterInvitesCommand(DiscordModule module) : base(module) {
|
public FilterInvitesCommand(DiscordModule module) : base(module) {
|
||||||
NadekoBot.Client.MessageReceived += async (sender, args) => {
|
NadekoBot.Client.MessageReceived += async (sender, args) => {
|
||||||
|
if (args.Channel.IsPrivate) return;
|
||||||
try {
|
try {
|
||||||
ServerPermissions serverPerms;
|
ServerPermissions serverPerms;
|
||||||
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
||||||
|
|
||||||
if (filterRegex.IsMatch(args.Message.RawText)) {
|
if (filterRegex.IsMatch(args.Message.RawText)) {
|
||||||
await args.Message.Delete();
|
await args.Message.Delete();
|
||||||
|
IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
|
||||||
|
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
||||||
|
$"Full message: [[{args.Message.Text}]]");
|
||||||
if (serverPerms.Verbose)
|
if (serverPerms.Verbose)
|
||||||
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not allowed on this channel.");
|
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " +
|
||||||
|
$"allowed on this channel.");
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ namespace NadekoBot.Modules {
|
|||||||
commands.Add(new PlayingRotate(this));
|
commands.Add(new PlayingRotate(this));
|
||||||
commands.Add(new RatelimitCommand(this));
|
commands.Add(new RatelimitCommand(this));
|
||||||
commands.Add(new VoicePlusTextCommand(this));
|
commands.Add(new VoicePlusTextCommand(this));
|
||||||
//commands.Add(new CrossServerTextChannel(this));
|
commands.Add(new CrossServerTextChannel(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Administration;
|
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Administration;
|
||||||
|
@ -16,7 +16,7 @@ namespace NadekoBot.Modules {
|
|||||||
commands.Add(new Trivia(this));
|
commands.Add(new Trivia(this));
|
||||||
commands.Add(new SpeedTyping(this));
|
commands.Add(new SpeedTyping(this));
|
||||||
commands.Add(new PollCommand(this));
|
commands.Add(new PollCommand(this));
|
||||||
commands.Add(new BetrayGame(this));
|
//commands.Add(new BetrayGame(this));
|
||||||
_8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray();
|
_8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@
|
|||||||
<Compile Include="Classes\ClashOfClans\ClashOfClans.cs" />
|
<Compile Include="Classes\ClashOfClans\ClashOfClans.cs" />
|
||||||
<Compile Include="Classes\DBHandler.cs" />
|
<Compile Include="Classes\DBHandler.cs" />
|
||||||
<Compile Include="Classes\FlowersHandler.cs" />
|
<Compile Include="Classes\FlowersHandler.cs" />
|
||||||
|
<Compile Include="Classes\IncidentsHandler.cs" />
|
||||||
<Compile Include="Classes\JSONModels\AnimeResult.cs" />
|
<Compile Include="Classes\JSONModels\AnimeResult.cs" />
|
||||||
<Compile Include="Classes\JSONModels\Configuration.cs" />
|
<Compile Include="Classes\JSONModels\Configuration.cs" />
|
||||||
<Compile Include="Classes\JSONModels\LocalizedStrings.cs" />
|
<Compile Include="Classes\JSONModels\LocalizedStrings.cs" />
|
||||||
@ -144,6 +145,7 @@
|
|||||||
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
||||||
<Compile Include="Commands\BetrayGame.cs" />
|
<Compile Include="Commands\BetrayGame.cs" />
|
||||||
|
<Compile Include="Commands\CrossServerTextChannel.cs" />
|
||||||
<Compile Include="Modules\ClashOfClans.cs" />
|
<Compile Include="Modules\ClashOfClans.cs" />
|
||||||
<Compile Include="Commands\FilterWordsCommand.cs" />
|
<Compile Include="Commands\FilterWordsCommand.cs" />
|
||||||
<Compile Include="Commands\FilterInvitesCommand.cs" />
|
<Compile Include="Commands\FilterInvitesCommand.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user