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 ); } }
public virtual void ReloadConfiguration(JObject newConfig) { Config = new QuotesConfig(newConfig); PostConfigReload(); }