Beispiel #1
0
        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);
 }
Beispiel #4
0
 public LeftChatMemberHandler(
     TelegramService telegramService,
     AntiSpamService antiSpamService
     )
 {
     _telegramService = telegramService;
     _antiSpamService = antiSpamService;
 }
Beispiel #5
0
		public CommandHandler(DiscordSocketClient client)
		{
			_commands = new CommandService();
			_antiSpam = new AntiSpamService();
			_client = client;

			_services = new ServiceCollection().AddSingleton(this).BuildServiceProvider();
		}
Beispiel #6
0
 public NewChatMembersService(
     ILogger <NewChatMembersService> logger,
     AntiSpamService antiSpamService,
     SettingsService settingsService
     )
 {
     _logger          = logger;
     _antiSpamService = antiSpamService;
     _settingsService = settingsService;
 }
Beispiel #7
0
        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();
        }
Beispiel #8
0
 public async Task ClearBlackListAsync(string clear)
 {
     if (clear.Contains("clear"))
     {
         AntiSpamService.ClearList();
         await ReplyAsync("Cleared the blacklist");
     }
     else
     {
         return;
     }
 }
Beispiel #9
0
 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;
     }
 }
Beispiel #10
0
 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;
     }
 }
Beispiel #11
0
 /// <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;
 }
Beispiel #12
0
        public async Task ListWordsAsync()
        {
            var result = AntiSpamService.ListWords();

            await ReplyAsync(String.IsNullOrWhiteSpace(result)? "<emptyset>" : result);
        }
Beispiel #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="antiSpamService"></param>
 public AntiSpamModule(AntiSpamService antiSpamService)
 {
     _antiSpamService = antiSpamService;
 }
Beispiel #14
0
 public AntiSpamController(AntiSpamService antiSpamService, UserMessagesCountService userMessagesCountService)
 {
     this._antiSpamService     = antiSpamService;
     _userMessagesCountService = userMessagesCountService;
     this._strategy            = new SpamDetectingStrategy();
 }