private async Task HandleMessages(SocketMessage s) { var msg = s as SocketUserMessage; var context = new SocketCommandContext(_client, msg); if (context.Message.Author == _client.CurrentUser) { return; } if (string.IsNullOrWhiteSpace(msg.Content.ToString())) { return; } List <string> BadWords = AntiSpamService.GetWords(); for (int i = 0; i < BadWords.Count; i++) { if (msg.Author.Id != context.Client.CurrentUser.Id) { if (msg.Content.ToUpper().Contains(BadWords[i].ToUpper())) { await msg.Author.SendMessageAsync($"Your message in `{context.Guild.Name}` - `#{context.Channel.Name}` has been deleted due to the antispam preferences."); await msg.DeleteAsync(); } } } }
/// <summary> /// /// </summary> /// <param name="settingsService"></param> /// <param name="antiSpamService"></param> public NewMemberHandler( SettingsService settingsService, AntiSpamService antiSpamService ) { _settingsService = settingsService; _antiSpamService = antiSpamService; }
public AntiSpamController(ServerMessagesCacheService serverMessagesCacheService, CheckUserSafetyService checkUserSafetyService, PunishmentsCachingService punishmentsCachingService, AntiSpamService antiSpamService, ConfigurationService configurationService) { this._serverMessagesCacheService = serverMessagesCacheService; this._punishmentsCachingService = punishmentsCachingService; this._antiSpamService = antiSpamService; this._overallSpamDetector = OverallSpamDetectorStrategy.GetStrategyWithDefaultDetectors(serverMessagesCacheService, checkUserSafetyService, configurationService); this._spamPunishmentStrategy = new SpamPunishmentStrategy(punishmentsCachingService); }
public LeftChatMemberHandler( TelegramService telegramService, AntiSpamService antiSpamService ) { _telegramService = telegramService; _antiSpamService = antiSpamService; }
public CommandHandler(DiscordSocketClient client) { _commands = new CommandService(); _antiSpam = new AntiSpamService(); _client = client; _services = new ServiceCollection().AddSingleton(this).BuildServiceProvider(); }
public NewChatMembersService( ILogger <NewChatMembersService> logger, AntiSpamService antiSpamService, SettingsService settingsService ) { _logger = logger; _antiSpamService = antiSpamService; _settingsService = settingsService; }
public CommandHandler(DiscordSocketClient client) { commands = new CommandService(); antiSpam = new AntiSpamService(); this.client = client; services = new ServiceCollection().AddSingleton(this) .AddSingleton(new YouTubeService(Global.HttpClient)) .AddSingleton(new GoogleService()) .BuildServiceProvider(); }
public async Task ClearBlackListAsync(string clear) { if (clear.Contains("clear")) { AntiSpamService.ClearList(); await ReplyAsync("Cleared the blacklist"); } else { return; } }
public async Task RemoveWordFromBlacklistAsync(string remove, [Remainder] string word) { if (remove.Contains("remove")) { AntiSpamService.RemoveWord(word); await ReplyAsync($"Removed `{word}` from the blacklist."); } else { return; } }
public async Task AddWordToBlackListAsync(string add, [Remainder] string word) { if (add.Contains("add")) { AntiSpamService.AddWord(word); await ReplyAsync($"Added `{word}` to the blacklist."); } else { return; } }
/// <summary> /// Instantiate UpdateHandler /// </summary> /// <param name="logger"></param> /// <param name="chatRestrictionModule"></param> /// <param name="antiSpamService"></param> /// <param name="settingsService"></param> /// <param name="wordFilterService"></param> public UpdateHandler( ILogger <UpdateHandler> logger, ChatRestrictionModule chatRestrictionModule, AntiSpamService antiSpamService, SettingsService settingsService, WordFilterService wordFilterService ) { _logger = logger; _chatRestrictionModule = chatRestrictionModule; _antiSpamService = antiSpamService; _settingsService = settingsService; _wordFilterService = wordFilterService; }
public async Task ListWordsAsync() { var result = AntiSpamService.ListWords(); await ReplyAsync(String.IsNullOrWhiteSpace(result)? "<emptyset>" : result); }
/// <summary> /// /// </summary> /// <param name="antiSpamService"></param> public AntiSpamModule(AntiSpamService antiSpamService) { _antiSpamService = antiSpamService; }
public AntiSpamController(AntiSpamService antiSpamService, UserMessagesCountService userMessagesCountService) { this._antiSpamService = antiSpamService; _userMessagesCountService = userMessagesCountService; this._strategy = new SpamDetectingStrategy(); }