Exemplo n.º 1
0
        public TriviaPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new TriviaConfig(config);
            GameState         = null;
            Randomizer        = new Random();

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

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("question"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleQuestionCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("starttrivia"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleStartTriviaCommand
                );
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("stoptrivia"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleStopTriviaCommand
                );
        }
Exemplo n.º 2
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
                );
        }
Exemplo n.º 3
0
        public CasinoPlayerBotPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new PlayerConfig(config);
            Dispatcher        = new EventDispatcher();
            State             = new BlackjackState();
            Randomizer        = new Random();
            CardCounter       = TabularCardCounter.Zen.Value;
            AssistPlayers     = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            StrategyDebuggers = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            ConnectionManager.ChannelMessage += HandleChannelMessage;
            ConnectionManager.QueryMessage   += HandleQueryMessage;
            ConnectionManager.QueryNotice    += HandleQueryNotice;

            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("casinoassist", "nocasinoassist"),
                    CommandUtil.NoOptions,
                    CommandUtil.NoArguments
                    ),
                HandleCasinoAssistCommand
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("stratdebug", "nostratdebug"),
                    CommandUtil.NoOptions,
                    CommandUtil.NoArguments
                    ),
                HandleStratDebugCommand
                );
        }
Exemplo n.º 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
                );
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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
                );
        }
Exemplo n.º 8
0
        public LinkInfoPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new LinkInfoConfig(config);
            IDNMapping        = new IdnMapping();
            Plugins           = new List <ILinkResolverPlugin>();

            LastLinkAndInfo = null;
            LinkDetector    = null;

            ConnectionManager.ChannelMessage         += HandleChannelMessage;
            ConnectionManager.OutgoingChannelMessage += HandleOutgoingChannelMessage;
            ConnectionManager.SplitToChunks          += HandleSplitToChunks;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("ll", "lastlink"),
                    CommandUtil.NoOptions,
                    CommandUtil.NoArguments,
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleLastLinkCommand
                );

            RepopulatePluginList();
        }
Exemplo n.º 9
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
                );
        }
Exemplo n.º 10
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
                );
        }
Exemplo n.º 12
0
        public LinkInfoOptInPlugin(IConnectionManager connMgr, JObject config)
            : base(connMgr, config)
        {
            Config = new LinkInfoOptInConfig(config);

            ConnectionManager.BaseNickChanged += HandleBaseNickChanged;

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("autolinkinfo", "noautolinkinfo"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleAutoLinkInfoCommand
                );
        }
Exemplo n.º 13
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)
                            );
                    }
                }
            }
        }
Exemplo n.º 14
0
        public ProverbPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new ProverbConfig(config);

            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("sprichwort"),
                    CommandUtil.NoOptions,
                    CommandUtil.NoArguments,
                    CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleProverbCommand
                );
        }
Exemplo n.º 15
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
                );
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
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();
        }
Exemplo n.º 18
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
                );
        }
Exemplo n.º 19
0
        public SmileysPlugin(IConnectionManager connMgr, JObject config)
        {
            ConnectionManager = connMgr;
            Config            = new SmileysConfig(config);

            // it's a fun command in a channel and a useful command in private message
            ConnectionManager.CommandManager.RegisterChannelMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("smileys", "smilies"),
                    tags: CommandUtil.MakeTags("fun"),
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleSmileysCommand
                );
            ConnectionManager.CommandManager.RegisterQueryMessageCommandHandler(
                new Command(
                    CommandUtil.MakeNames("smileys", "smilies"),
                    tags: CommandUtil.NoTags,
                    forbiddenFlags: MessageFlags.UserBanned
                    ),
                HandleSmileysCommand
                );
        }
Exemplo n.º 20
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
                );
        }
Exemplo n.º 21
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();
        }
Exemplo n.º 22
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
                    );
            }
        }
Exemplo n.º 23
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
                );
        }
Exemplo n.º 24
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
                );
        }
Exemplo n.º 25
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;
        }