Fixed possible bot loops, as well as self-moderation.

This commit is contained in:
Master Kwoth 2016-03-19 09:34:28 +01:00
parent d2698f84ca
commit 8304d915d4
9 changed files with 10 additions and 8 deletions

View File

@ -10,7 +10,7 @@ using Newtonsoft.Json;
namespace NadekoBot.Classes {
internal class SpecificConfigurations {
public static SpecificConfigurations Default { get; } = new SpecificConfigurations();
public static bool Instantiated { get; set; } = false;
public static bool Instantiated { get; private set; }
private const string filePath = "data/ServerSpecificConfigs.json";

View File

@ -96,6 +96,7 @@ namespace NadekoBot.Classes.Trivia {
try {
if (e.Channel.IsPrivate) return;
if (e.Server != server) return;
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
var guess = false;
lock (_guessLock) {

View File

@ -13,6 +13,7 @@ namespace NadekoBot.Commands {
}
private async void Client_MessageReceived(object sender, Discord.MessageEventArgs e) {
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
try {
if (string.IsNullOrWhiteSpace(e.Message.Text))
return;

View File

@ -12,7 +12,7 @@ namespace NadekoBot.Commands {
public CrossServerTextChannel(DiscordModule module) : base(module) {
NadekoBot.Client.MessageReceived += async (s, e) => {
try {
if (e.Message.User.Id == NadekoBot.Creds.BotId) return;
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
foreach (var subscriber in Subscribers) {
var set = subscriber.Value;
if (!set.Contains(e.Channel))
@ -25,7 +25,7 @@ namespace NadekoBot.Commands {
};
NadekoBot.Client.MessageUpdated += async (s, e) => {
try {
if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Creds.BotId) return;
if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Client.CurrentUser.Id) return;
foreach (var subscriber in Subscribers) {
var set = subscriber.Value;
if (!set.Contains(e.Channel))

View File

@ -18,7 +18,7 @@ namespace NadekoBot.Commands {
public FilterInvitesCommand(DiscordModule module) : base(module) {
NadekoBot.Client.MessageReceived += async (sender, args) => {
if (args.Channel.IsPrivate) return;
if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return;
try {
ServerPermissions serverPerms;
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;

View File

@ -15,7 +15,7 @@ namespace NadekoBot.Commands {
internal class FilterWords : DiscordCommand {
public FilterWords(DiscordModule module) : base(module) {
NadekoBot.Client.MessageReceived += async (sender, args) => {
if (args.Channel.IsPrivate) return;
if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return;
try {
ServerPermissions serverPerms;
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;

View File

@ -25,7 +25,7 @@ namespace NadekoBot.Commands {
NadekoBot.Client.MessageReceived += async (s, e) => {
if (e.Channel.IsPrivate)
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
return;
if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
try {

View File

@ -13,7 +13,7 @@ namespace NadekoBot.Commands {
public RatelimitCommand(DiscordModule module) : base(module) {
NadekoBot.Client.MessageReceived += async (s, e) => {
if (e.Channel.IsPrivate)
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
return;
ConcurrentDictionary<ulong, DateTime> userTimePair;
if (!RatelimitingChannels.TryGetValue(e.Channel.Id, out userTimePair)) return;

View File

@ -88,7 +88,7 @@ namespace NadekoBot.Commands {
private async void AnswerReceived(object sender, MessageEventArgs e) {
try {
if (e.Channel == null || e.Channel.Id != channel.Id) return;
if (e.Channel == null || e.Channel.Id != channel.Id || e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
var guess = e.Message.RawText;