示例#1
0
        public AlsoKnownAsPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new AlsoKnownAsConfig(config);

            HostToNicks          = new DrillDownTree <string, HashSet <string> >();
            NickToMostRecentHost = new Dictionary <string, UserIdentifier>(StringComparer.OrdinalIgnoreCase);

            var akaCommand = new Command(
                CommandUtil.MakeNames("aka"),
                CommandUtil.NoOptions,
                CommandUtil.MakeArguments(
                    CommandUtil.NonzeroStringMatcherRequiredWordTaker // nickname
                    ),
                forbiddenFlags: MessageFlags.UserBanned
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                akaCommand, HandleChannelAka
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                akaCommand, HandleQueryAka
                );

            ConnectionManager.JoinedChannel += HandleJoinedChannel;
            ConnectionManager.NickChange    += HandleNickChange;
            ConnectionManager.RawMessage    += HandleRawMessage;
        }
示例#2
0
        protected virtual void ReregisterCommands()
        {
            var currentCommandCopy = new List <Command>(CurrentCommands);

            foreach (Command command in currentCommandCopy)
            {
                ConnectionManager.CommandManager.UnregisterChannelMessageCommandHandler(
                    command,
                    HandleCounterCommand
                    );
                CurrentCommands.Remove(command);
            }

            foreach (Counter counter in Config.Counters)
            {
                var command = new Command(
                    CommandUtil.MakeNames(counter.CommandName),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                    command,
                    HandleCounterCommand
                    );
                CurrentCommands.Add(command);
            }
        }
示例#3
0
        public TimePlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new TimeConfig(config);

            LoadTimeZoneData();

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("time", "ltime"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // location
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleTimeCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("interval"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // date/time
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleIntervalCommand
                );
        }
示例#4
0
        public BelchPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("belch"),
                    CommandUtil.NoOptions,
                    CommandUtil.NoArguments,
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleBelchCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("skittles"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleSkittlesCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("tel"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleTelCommand
                );
        }
示例#5
0
        public IKnewThatPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new IKnewThatConfig(config);

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("iknewthat"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // keyword
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleIKnewThatChannelCommand
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("iknowthat"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // keyword
                        RestTaker.Instance                                 // description
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleIKnowThatQueryCommand
                );
        }
示例#6
0
        public AllographPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager   = connMgr;
            Config              = new AllographConfig(config);
            Random              = new Random();
            CooldownsPerChannel = new Dictionary <string, List <int> >();
            ReplacerRegexes     = new List <ReplacerRegex>();

            RecompileReplacerRegexes();

            ConnectionManager.ChannelMessage += HandleChannelMessage;

            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("allostats"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        new RegexMatcher("^[#&]\\S{1,256}$").ToRequiredWordTaker(), // channel name
                        RestTaker.Instance                                          // test message (optional)
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleAlloStatsCommand
                );
        }
示例#7
0
        public DicePlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new DiceConfig(config);
            RNG               = new Random();
            CryptoRNG         = new CryptoRandom();
            ChannelToCooldown = new Dictionary <string, CooldownState>();

            ImmutableList <KeyValuePair <string, IArgumentTaker> > cryptoOption =
                CommandUtil.MakeOptions(
                    CommandUtil.MakeFlag("--crypto")
                    )
            ;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("roll"),
                    cryptoOption,
                    CommandUtil.MakeArguments(new MultiMatchTaker(RollRegex, RollSeparatorRegex, 1)),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleRollCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("yn"),
                    cryptoOption,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleYesNoCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("decide"),
                    cryptoOption,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleDecideCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("shuffle"),
                    cryptoOption,
                    CommandUtil.MakeArguments(RestTaker.Instance),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleShuffleCommand
                );
            ConnectionManager.ChannelMessage += HandleChannelMessage;
        }
        public DatabaseNickMappingPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new DatabaseNickMappingConfig(config);

            ConnectionManager.NickMapping += HandleNickMapping;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("linknicks"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // first nick (base)
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker  // second nick (alias)
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleLinkNicksCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("unlinknick"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nick
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleUnlinkNickCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("basenick"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nick
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleBaseNickCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("pseudoregister", "pseudounregister"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nick
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandlePseudoRegisterCommand
                );
        }
示例#9
0
        public BanKitPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new BanKitConfig(config);

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("tb", "timeban", "timedban", "tkb"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // nickname
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // timespan
                        RestTaker.Instance                                 // message
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleTimedBanCommand
                );

            if (Config.PersistBans)
            {
                // load persisted bans
                List <BanEntry> entriesToSchedule;
                using (BanKitContext ctx = GetNewContext())
                {
                    entriesToSchedule = ctx.BanEntries
                                        .Where(be => !be.Lifted)
                                        .ToList();
                }

                foreach (BanEntry ban in entriesToSchedule)
                {
                    if (ban.TimestampBanEnd <= DateTimeOffset.Now)
                    {
                        // unban immediately
                        UnbanChannelMask(ban.Channel, ban.BannedMask);
                    }
                    else
                    {
                        // schedule for later
                        ConnectionManager.Timers.Register(
                            ban.TimestampBanEnd,
                            () => UnbanChannelMask(ban.Channel, ban.BannedMask)
                            );
                    }
                }
            }
        }
示例#10
0
        public ReinvitePlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new ReinviteConfig(config);

            ConnectionManager.Invited += HandleInvite;

            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("invite"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        new RegexMatcher("^[#&]\\S{1,256}").ToRequiredWordTaker() // channel name
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleInviteCommand
                );
        }
示例#11
0
        public VitalsPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new VitalsConfig(config);
            NameToReader      = new Dictionary <string, IVitalsReader>();

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("vitals", "vit"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // location
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleVitalsCommand
                );

            RecreateReaders();
        }
示例#12
0
        public WeatherPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new WeatherConfig(config);
            WeatherProviders  = new List <IWeatherProvider>();

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("weather", "lweather"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // location
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleWeatherCommand
                );

            ReloadProviders();
        }
示例#13
0
        public WhoDoYouThinkIsPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;

            var wdytiCommand = new Command(
                CommandUtil.MakeNames("wdyti"),
                CommandUtil.NoOptions,
                CommandUtil.MakeArguments(
                    CommandUtil.NonzeroStringMatcherRequiredWordTaker // nickname
                    ),
                forbiddenFlags: MessageFlags.UserBanned
                );

            // it's a fun command in a channel and a useful command in private message
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("wdyti"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nickname
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleWDYTICommandInChannel
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("wdyti"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nickname
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleWDYTICommandInQuery
                );
        }
示例#14
0
        public SockpuppetPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new SockpuppetConfig(config);

            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("sockpuppet"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // raw IRC command
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleSockpuppetCommand
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("reload"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleReloadCommand
                );
        }
示例#15
0
        public QuotesPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager         = connMgr;
            Config                    = new QuotesConfig(config);
            PotentialQuotesPerChannel = new Dictionary <string, List <Quote> >();
            LastQuoteIDs              = new Dictionary <string, long>();
            Randomizer                = new Random();

            ConnectionManager.ChannelMessage  += HandleChannelMessage;
            ConnectionManager.ChannelAction   += HandleChannelAction;
            ConnectionManager.BaseNickChanged += HandleBaseNickChanged;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("addquote"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // quote body
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleAddQuoteCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("remember"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // quote author
                        RestTaker.Instance                                 // search string
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleRememberCommand
                );

            {
                var quoteCommand = new Command(
                    CommandUtil.MakeNames("quote"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--any"),
                        CommandUtil.MakeFlag("--bad"),
                        CommandUtil.MakeFlag("-r")
                        ),
                    CommandUtil.MakeArguments(
                        RestTaker.Instance // search string (optional)
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(quoteCommand, HandleQuoteCommand);
                ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(quoteCommand, HandleQuoteCommand);
            }

            {
                var quoteUserCommand = new Command(
                    CommandUtil.MakeNames("quoteuser"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--any"),
                        CommandUtil.MakeFlag("--bad"),
                        CommandUtil.MakeFlag("-r")
                        ),
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // nickname
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                    quoteUserCommand, HandleQuoteUserCommand
                    );
                ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                    quoteUserCommand, HandleQuoteUserCommand
                    );
            }

            {
                var nextQuoteCommand = new Command(
                    CommandUtil.MakeNames("nextquote"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--any"),
                        CommandUtil.MakeFlag("--bad"),
                        CommandUtil.MakeFlag("-r")
                        ),
                    CommandUtil.NoArguments,
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                    nextQuoteCommand, HandleNextQuoteCommand
                    );
                ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                    nextQuoteCommand, HandleNextQuoteCommand
                    );
            }

            {
                var upquoteCommand = new Command(
                    CommandUtil.MakeNames("upquote", "uq"),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                    upquoteCommand, HandleUpquoteCommand
                    );
                ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                    upquoteCommand, HandleUpquoteCommand
                    );
            }

            {
                var downquoteCommand = new Command(
                    CommandUtil.MakeNames("downquote", "dq"),
                    forbiddenFlags: MessageFlags.UserBanned
                    );
                ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                    downquoteCommand, HandleDownquoteCommand
                    );
                ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                    downquoteCommand, HandleDownquoteCommand
                    );
            }
        }
示例#16
0
        public ThanksPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new ThanksConfig(config);

            ConnectionManager.BaseNickChanged += HandleBaseNickChanged;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("thank", "thanks", "thx"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--force")
                        ),
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // target
                        RestTaker.Instance                                 // reason
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleThankCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("thanked"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--raw")
                        ),
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // target
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleThankedCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("grateful"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("--raw")
                        ),
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // target
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleGratefulCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("topthanked"),
                    tags: CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleTopThankedCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("topgrateful"),
                    tags: CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleTopGratefulCommand
                );
        }
示例#17
0
        public CountersPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new CountersConfig(config);
            CurrentCommands   = new HashSet <Command>();
            ChannelsMessages  = new Dictionary <string, RingBuffer <ChannelMessage> >();

            ReregisterCommands();

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("uncount"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // counter name
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleUncountCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("regexcount"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // counter name
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // nickname
                        RestTaker.Instance                                 // regex
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleRegexCountCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("counted"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // counter name
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleCountedCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("counterstats"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // counter name
                        ),
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleCounterStatsCommand
                );

            ConnectionManager.ChannelMessage  += HandleChannelMessage;
            ConnectionManager.BaseNickChanged += HandleBaseNickChanged;
        }
示例#18
0
        public UnoGameMasterPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new GameMasterConfig(config);

            AttackMode           = false;
            ExtremeMode          = false;
            DrawPile             = new Pile <Card>();
            DiscardPile          = new Pile <Card>();
            Players              = new List <Player>();
            CurrentPlayerIndex   = 0;
            PlayerOrderReversed  = false;
            DrewLast             = true;
            CurrentGameState     = GameState.NoGame;
            TurnStartedUtc       = null;
            TurnTickTimer        = new Timer(TurnTickTimerElapsed, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
            TurnLock             = new object();
            Randomizer           = new Random();
            BotTestCount         = 0;
            BotTestJoinRequested = null;

            ConnectionManager.NickChange      += HandleNickChange;
            ConnectionManager.UserLeftChannel += HandleUserLeftChannel;
            ConnectionManager.UserQuitServer  += HandleUserQuitServer;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("uno"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeFlag("+a"),
                        CommandUtil.MakeFlag("+e")
                        ),
                    CommandUtil.NoArguments,
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleUnoCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("play", "p"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // color or wildcard value
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker  // value or change-to-color
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandlePlayCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("bottest"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        new LongMatcher().ToRequiredWordTaker() // number of rounds
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleBotTestCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("join", "botjoin"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleJoinCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("leave"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleLeaveCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("deal"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleDealCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("draw"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleDrawCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("pass"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandlePassCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("endgame"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleEndGameCommand
                );
        }
示例#19
0
        public DemoderationPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new DemoderationConfig(config);

            ChannelsMessages = new Dictionary <string, RingBuffer <ChannelMessage> >();
            RegexCache       = new RegexCache();

            ConnectionManager.ChannelMessage += HandleChannelMessage;
            CleanupTimer = new Timer(
                CleanupTimerElapsed, null, TimeSpan.Zero, TimeSpan.FromMinutes(Config.CleanupPeriodMinutes)
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmabuse"),
                    CommandUtil.MakeOptions(
                        CommandUtil.MakeOption("-b", CommandUtil.NonzeroStringMatcherRequiredWordTaker),
                        CommandUtil.MakeOption("--ban-time", CommandUtil.NonzeroStringMatcherRequiredWordTaker),
                        CommandUtil.MakeOption("-c", CommandUtil.NonzeroStringMatcherRequiredWordTaker),
                        CommandUtil.MakeOption("--cooldown-time", CommandUtil.NonzeroStringMatcherRequiredWordTaker)
                        ),
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // nickname
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker  // criterion name
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleAbuseCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmnew"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker, // criterion name
                        RestTaker.Instance                                 // criterion detection regex
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleNewCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmdel"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // criterion name
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleDeleteCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmrestore"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker // criterion name
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleRestoreCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmimmunity"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker,                // nickname
                        new RegexMatcher("(?:[#+&][^ ,:]+|GLOBAL)").ToRequiredWordTaker() // channel or "GLOBAL"
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleImmunityCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmdelimmunity"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker,                // nickname
                        new RegexMatcher("(?:[#+&][^ ,:]+|GLOBAL)").ToRequiredWordTaker() // channel or "GLOBAL"
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleDeleteImmunityCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmpermaban"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker,                // nickname
                        new RegexMatcher("(?:[#+&][^ ,:]+|GLOBAL)").ToRequiredWordTaker() // channel or "GLOBAL"
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandlePermabanCommand
                );

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("dmunpermaban"),
                    CommandUtil.NoOptions,
                    CommandUtil.MakeArguments(
                        CommandUtil.NonzeroStringMatcherRequiredWordTaker,                // nickname
                        new RegexMatcher("(?:[#+&][^ ,:]+|GLOBAL)").ToRequiredWordTaker() // channel or "GLOBAL"
                        ),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleUnPermabanCommand
                );

            UpdateCommandCache();
        }