Fixed possible bot loops, as well as self-moderation.
This commit is contained in:
parent
d2698f84ca
commit
8304d915d4
@ -10,7 +10,7 @@ using Newtonsoft.Json;
|
|||||||
namespace NadekoBot.Classes {
|
namespace NadekoBot.Classes {
|
||||||
internal class SpecificConfigurations {
|
internal class SpecificConfigurations {
|
||||||
public static SpecificConfigurations Default { get; } = new 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";
|
private const string filePath = "data/ServerSpecificConfigs.json";
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ namespace NadekoBot.Classes.Trivia {
|
|||||||
try {
|
try {
|
||||||
if (e.Channel.IsPrivate) return;
|
if (e.Channel.IsPrivate) return;
|
||||||
if (e.Server != server) return;
|
if (e.Server != server) return;
|
||||||
|
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
|
|
||||||
var guess = false;
|
var guess = false;
|
||||||
lock (_guessLock) {
|
lock (_guessLock) {
|
||||||
|
@ -13,6 +13,7 @@ namespace NadekoBot.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void Client_MessageReceived(object sender, Discord.MessageEventArgs e) {
|
private async void Client_MessageReceived(object sender, Discord.MessageEventArgs e) {
|
||||||
|
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
try {
|
try {
|
||||||
if (string.IsNullOrWhiteSpace(e.Message.Text))
|
if (string.IsNullOrWhiteSpace(e.Message.Text))
|
||||||
return;
|
return;
|
||||||
|
@ -12,7 +12,7 @@ namespace NadekoBot.Commands {
|
|||||||
public CrossServerTextChannel(DiscordModule module) : base(module) {
|
public CrossServerTextChannel(DiscordModule module) : base(module) {
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) => {
|
NadekoBot.Client.MessageReceived += async (s, e) => {
|
||||||
try {
|
try {
|
||||||
if (e.Message.User.Id == NadekoBot.Creds.BotId) return;
|
if (e.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
foreach (var subscriber in Subscribers) {
|
foreach (var subscriber in Subscribers) {
|
||||||
var set = subscriber.Value;
|
var set = subscriber.Value;
|
||||||
if (!set.Contains(e.Channel))
|
if (!set.Contains(e.Channel))
|
||||||
@ -25,7 +25,7 @@ namespace NadekoBot.Commands {
|
|||||||
};
|
};
|
||||||
NadekoBot.Client.MessageUpdated += async (s, e) => {
|
NadekoBot.Client.MessageUpdated += async (s, e) => {
|
||||||
try {
|
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) {
|
foreach (var subscriber in Subscribers) {
|
||||||
var set = subscriber.Value;
|
var set = subscriber.Value;
|
||||||
if (!set.Contains(e.Channel))
|
if (!set.Contains(e.Channel))
|
||||||
|
@ -18,7 +18,7 @@ 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;
|
if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
try {
|
try {
|
||||||
ServerPermissions serverPerms;
|
ServerPermissions serverPerms;
|
||||||
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
||||||
|
@ -15,7 +15,7 @@ namespace NadekoBot.Commands {
|
|||||||
internal class FilterWords : DiscordCommand {
|
internal class FilterWords : DiscordCommand {
|
||||||
public FilterWords(DiscordModule module) : base(module) {
|
public FilterWords(DiscordModule module) : base(module) {
|
||||||
NadekoBot.Client.MessageReceived += async (sender, args) => {
|
NadekoBot.Client.MessageReceived += async (sender, args) => {
|
||||||
if (args.Channel.IsPrivate) return;
|
if (args.Channel.IsPrivate || args.User.Id == NadekoBot.Client.CurrentUser.Id) return;
|
||||||
try {
|
try {
|
||||||
ServerPermissions serverPerms;
|
ServerPermissions serverPerms;
|
||||||
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
if (!IsChannelOrServerFiltering(args.Channel, out serverPerms)) return;
|
||||||
|
@ -25,7 +25,7 @@ namespace NadekoBot.Commands {
|
|||||||
|
|
||||||
|
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) => {
|
NadekoBot.Client.MessageReceived += async (s, e) => {
|
||||||
if (e.Channel.IsPrivate)
|
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
return;
|
||||||
if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
|
if (!SpecificConfigurations.Default.Of(e.Server.Id).SendPrivateMessageOnMention) return;
|
||||||
try {
|
try {
|
||||||
|
@ -13,7 +13,7 @@ namespace NadekoBot.Commands {
|
|||||||
|
|
||||||
public RatelimitCommand(DiscordModule module) : base(module) {
|
public RatelimitCommand(DiscordModule module) : base(module) {
|
||||||
NadekoBot.Client.MessageReceived += async (s, e) => {
|
NadekoBot.Client.MessageReceived += async (s, e) => {
|
||||||
if (e.Channel.IsPrivate)
|
if (e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id)
|
||||||
return;
|
return;
|
||||||
ConcurrentDictionary<ulong, DateTime> userTimePair;
|
ConcurrentDictionary<ulong, DateTime> userTimePair;
|
||||||
if (!RatelimitingChannels.TryGetValue(e.Channel.Id, out userTimePair)) return;
|
if (!RatelimitingChannels.TryGetValue(e.Channel.Id, out userTimePair)) return;
|
||||||
|
@ -88,7 +88,7 @@ namespace NadekoBot.Commands {
|
|||||||
|
|
||||||
private async void AnswerReceived(object sender, MessageEventArgs e) {
|
private async void AnswerReceived(object sender, MessageEventArgs e) {
|
||||||
try {
|
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;
|
var guess = e.Message.RawText;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user