Beispiel #1
0
        private void ProcessQuit(IrcIdentity ident, string channelName, SpamConfig channel)
        {
            var nickname = ident.Nickname;

            Whois.NormalizeIdentity(ident);

            var quits = channel.AddUserPart(ident.ToString(), channel.QuitsThresholdSeconds);

            if (quits < channel.QuitsThreshold)
            {
                return;
            }

            channel.ResetUserPart(ident.ToString());

            Log.WriteInfo("Spam", "'{1}' ({0}) is spamming joins/quits in {2}. Redirecting for {3} minutes.", nickname, ident, channelName, channel.QuitsBanMinutes);

            Bootstrap.Client.Client.Mode(channelName, "+b", ident + "$" + Bootstrap.Client.Settings.RedirectChannel);

            // In case they manage to come back before ban takes place
            Bootstrap.Client.Client.Kick(nickname, channelName, string.Format("Fix your connection. Banned for {0} minutes", channel.QuitsBanMinutes));

            Bootstrap.Client.Client.Notice(nickname, string.Format("You have been banned from {0} for {1} minutes for rapidly rejoining the channel.", channelName, channel.QuitsBanMinutes));

            Bootstrap.Client.ModeList.AddLateModeRequest(
                new LateModeRequest
            {
                Channel   = channelName,
                Recipient = ident.ToString(),
                Mode      = "-b",
                Time      = DateTime.UtcNow.AddMinutes(channel.QuitsBanMinutes),
                Reason    = "Quit/leave flood"
            }
                );
        }
Beispiel #2
0
        private void ProcessQuit(IrcIdentity ident, string channelName, SpamConfig channel)
        {
            var nickname = ident.Nickname;

            ident = Whois.NormalizeIdentity(ident);

            var quits = channel.AddUserPart(ident.ToString(), channel.QuitsThresholdSeconds);

            if (quits < channel.QuitsThreshold)
            {
                return;
            }

            var banMinutes = channel.AddUserBan(ident.ToString()) * channel.QuitsBanMinutes;

            Log.WriteInfo("Spam", "'{1}' ({0}) is spamming joins/quits in {2}. Redirecting for {3} minutes.", nickname, ident, channelName, banMinutes);

            Bootstrap.Client.Client.Mode(channelName, "+b", ident + "$" + Bootstrap.Client.Settings.RedirectChannel);

            // In case they manage to come back before ban takes place
            Bootstrap.Client.Client.Kick(nickname, channelName, $"Fix your connection. Banned for {banMinutes} minutes");

            Bootstrap.Client.Client.Notice(nickname, $"Please fix your connection. You have been banned from {channelName} for {banMinutes} minutes for rapidly rejoining the channel.");

            if (Bootstrap.Client.ModeList.Find(channelName, ident.ToString(), "-b") != null)
            {
                Log.WriteInfo("Spam", "There's already a latemode set for '{0}' in {1}", ident, channelName);

                return;
            }

            Bootstrap.Client.ModeList.AddLateModeRequest(
                new LateModeRequest
            {
                Channel   = channelName,
                Recipient = ident.ToString(),
                Mode      = "-b",
                Time      = DateTime.UtcNow.AddMinutes(banMinutes),
                Reason    = "Quit/leave flood"
            }
                );
        }