예제 #1
0
        public RecentChangeHandler(
            IAppConfiguration appConfig,
            ILogger logger,
            IChannelConfiguration channelConfig,
            IBotUserConfiguration botUserConfiguration,
            IIrcClient freenodeClient,
            IEmailHelper emailHelper,
            INotificationTemplates templates,
            IEmailTemplateFormatter emailTemplateFormatter,
            ISubscriptionHelper subscriptionHelper)
        {
            this.appConfig              = appConfig;
            this.logger                 = logger;
            this.channelConfig          = channelConfig;
            this.botUserConfiguration   = botUserConfiguration;
            this.freenodeClient         = freenodeClient;
            this.emailHelper            = emailHelper;
            this.templates              = templates;
            this.emailTemplateFormatter = emailTemplateFormatter;
            this.subscriptionHelper     = subscriptionHelper;

            if (this.appConfig.EmailConfiguration == null)
            {
                this.logger.Warn("Not sending email; email configuration is disabled");
            }
        }
예제 #2
0
 public AccountCommand(string commandSource,
                       IUser user,
                       IList <string> arguments,
                       ILogger logger,
                       IFlagService flagService,
                       IConfigurationProvider configurationProvider,
                       IIrcClient client,
                       IBotUserConfiguration botUserConfiguration,
                       IEmailHelper emailHelper,
                       IAppConfiguration config,
                       INotificationTemplates templates,
                       IChannelConfiguration channelConfiguration) : base(
         commandSource,
         user,
         arguments,
         logger,
         flagService,
         configurationProvider,
         client)
 {
     this.appConfig            = config;
     this.templates            = templates;
     this.channelConfiguration = channelConfiguration;
     this.botUserConfiguration = botUserConfiguration;
     this.emailHelper          = emailHelper;
 }
예제 #3
0
        public ChannelModule(
            IAppConfiguration appConfiguration,
            IIrcClient freenodeClient,
            IChannelConfiguration channelConfiguration,
            IBotUserConfiguration botUserConfiguration,
            IStalkNodeFactory stalkNodeFactory,
            ISubscriptionHelper subscriptionHelper,
            IFlagService flagService
            )
            : base(appConfiguration, freenodeClient)
        {
            this.channelConfiguration = channelConfiguration;
            this.botUserConfiguration = botUserConfiguration;
            this.stalkNodeFactory     = stalkNodeFactory;
            this.subscriptionHelper   = subscriptionHelper;
            this.flagService          = flagService;

            this.Get["/channels"]                                      = this.GetChannelList;
            this.Get["/channels/{channel}"]                            = this.GetChannelInfo;
            this.Get["/channels/{channel}/new"]                        = this.NewStalk;
            this.Post["/channels/{channel}/new"]                       = this.PostNewStalk;
            this.Post["/channels/{channel}/subscribe"]                 = this.ChannelSubscribe;
            this.Post["/channels/{channel}/unsubscribe"]               = this.ChannelUnsubscribe;
            this.Get["/channels/{channel}/stalk/{stalk}"]              = this.GetStalkInfo;
            this.Get["/channels/{channel}/stalk/{stalk}/edit"]         = this.GetStalkInfoForEdit;
            this.Get["/channels/{channel}/stalk/{stalk}/delete"]       = this.GetStalkInfoForDelete;
            this.Post["/channels/{channel}/stalk/{stalk}/delete"]      = this.DeleteStalk;
            this.Post["/channels/{channel}/stalk/{stalk}/edit"]        = this.PostStalkInfo;
            this.Post["/channels/{channel}/stalk/{stalk}/subscribe"]   = this.StalkSubscribe;
            this.Post["/channels/{channel}/stalk/{stalk}/unsubscribe"] = this.StalkUnsubscribe;
        }
        public ChangePasswordModule(IAppConfiguration appConfiguration, IIrcClient freenodeClient, IBotUserConfiguration botUserConfiguration) : base(
                appConfiguration,
                freenodeClient)
        {
            this.botUserConfiguration = botUserConfiguration;

            this.Get["/changepassword"]  = this.ChangePassword;
            this.Post["/changepassword"] = this.ChangePasswordPost;
        }
 public SubscriptionHelper(
     ILogger logger,
     IBotUserConfiguration botUserConfiguration,
     IChannelConfiguration channelConfiguration)
 {
     this.logger = logger;
     this.botUserConfiguration = botUserConfiguration;
     this.channelConfiguration = channelConfiguration;
 }
예제 #6
0
 public UserFlagService(
     IAppConfiguration appConfiguration,
     IBotUserConfiguration userConfiguration,
     IChannelConfiguration channelConfiguration)
 {
     this.appConfiguration     = appConfiguration;
     this.userConfiguration    = userConfiguration;
     this.channelConfiguration = channelConfiguration;
 }
예제 #7
0
        public LoginModule(IBotUserConfiguration botUserConfiguration, IAppConfiguration appConfiguration, IIrcClient freenodeClient)
        {
            this.botUserConfiguration = botUserConfiguration;
            this.appConfiguration     = appConfiguration;
            this.freenodeClient       = freenodeClient;

            this.Get["/login"]  = this.LogIn;
            this.Get["/logout"] = this.LogOut;
            this.Post["/login"] = this.LogInPost;
        }
예제 #8
0
        public UsersModule(
            IAppConfiguration appConfiguration,
            IIrcClient freenodeClient,
            IBotUserConfiguration botUserConfiguration) : base(
                appConfiguration,
                freenodeClient)
        {
            // this.RequiresClaims(AccessFlags.GlobalAdmin);

            this.botUserConfiguration = botUserConfiguration;
            this.Get["/users"]        = this.GetUserList;
        }
예제 #9
0
 public FlagsCommand(
     string commandSource,
     IUser user,
     IList <string> arguments,
     ILogger logger,
     IFlagService flagService,
     IConfigurationProvider configurationProvider,
     IIrcClient client,
     IBotUserConfiguration botUserConfiguration,
     IChannelConfiguration channelConfiguration)
     : base(commandSource, user, arguments, logger, flagService, configurationProvider, client)
 {
     this.botUserConfiguration = botUserConfiguration;
     this.channelConfiguration = channelConfiguration;
 }
예제 #10
0
 public ChannelCommand(
     string commandSource,
     IUser user,
     IList <string> arguments,
     ILogger logger,
     IFlagService flagService,
     IConfigurationProvider configurationProvider,
     IIrcClient client,
     IChannelConfiguration channelConfiguration,
     IBotUserConfiguration botUserConfiguration,
     IAppConfiguration appConfig, ISubscriptionHelper subscriptionHelper)
     : base(commandSource, user, arguments, logger, flagService, configurationProvider, client)
 {
     this.channelConfiguration = channelConfiguration;
     this.botUserConfiguration = botUserConfiguration;
     this.appConfig            = appConfig;
     this.subscriptionHelper   = subscriptionHelper;
 }
예제 #11
0
 public StalkCommand(
     string commandSource,
     IUser user,
     IList <string> arguments,
     ILogger logger,
     IFlagService flagService,
     IConfigurationProvider configurationProvider,
     IIrcClient client,
     IChannelConfiguration channelConfiguration,
     IStalkNodeFactory stalkNodeFactory,
     IAppConfiguration config,
     INotificationTemplates templates,
     IEmailHelper emailHelper,
     IXmlCacheService xmlCacheService,
     IBotUserConfiguration botUserConfiguration,
     ISubscriptionHelper subscriptionHelper,
     IIrcClient wikimediaClient,
     IEmailTemplateFormatter emailTemplateFormatter
     ) : base(
         commandSource,
         user,
         arguments,
         logger,
         flagService,
         configurationProvider,
         client)
 {
     this.channelConfiguration = channelConfiguration;
     this.config                 = config;
     this.templates              = templates;
     this.emailHelper            = emailHelper;
     this.xmlCacheService        = xmlCacheService;
     this.botUserConfiguration   = botUserConfiguration;
     this.subscriptionHelper     = subscriptionHelper;
     this.wikimediaClient        = wikimediaClient;
     this.emailTemplateFormatter = emailTemplateFormatter;
     this.stalkNodeFactory       = stalkNodeFactory;
 }
예제 #12
0
        public Launch(
            ILogger logger,
            IIrcClient freenodeClient,
            IIrcClient wikimediaClient,
            IAppConfiguration appConfig,
            ITemplateConfiguration templateConfiguration,
            IBotUserConfiguration userConfiguration,
            IChannelConfiguration channelConfiguration,
            IStalkFactory stalkFactory,
            IFileService fileService)
        {
            this.logger               = logger;
            this.freenodeClient       = freenodeClient;
            this.wikimediaClient      = wikimediaClient;
            this.appConfig            = appConfig;
            this.channelConfiguration = channelConfiguration;

            if (!this.channelConfiguration.Items.Any())
            {
                this.logger.InfoFormat("Migrating to channel configuration file...");

                var defaultChannel = new IrcChannel(this.appConfig.FreenodeChannel);
                this.channelConfiguration.Add(defaultChannel);

                if (appConfig.StalkConfigFile != null)
                {
                    var stalkConfig = new StalkConfiguration(
                        appConfig,
                        logger.CreateChildLogger("LegacyStalkConfig"),
                        stalkFactory,
                        fileService
                        );
                    stalkConfig.Initialize();

                    foreach (var stalk in stalkConfig.Items)
                    {
                        stalk.Channel = this.appConfig.FreenodeChannel;
                        defaultChannel.Stalks.Add(stalk.Identifier, stalk);
                        stalkConfig.Remove(stalk.Identifier);
                    }

                    stalkConfig.Save();
                }

                this.channelConfiguration.Save();
            }

            this.logger.InfoFormat(
                "Tracking {0} stalks, {1} templates, {2} users, and {3} channels.",
                this.channelConfiguration.Items.Aggregate(0, (i, channel) => i + channel.Stalks.Count),
                templateConfiguration.Items.Count,
                userConfiguration.Items.Count,
                channelConfiguration.Items.Count
                );

            if (appConfig.MetricsPort != 0)
            {
                this.logger.DebugFormat("Setting up metrics server on port {0}", appConfig.MetricsPort);
                this.metricsServer = new MetricServer(appConfig.MetricsPort);
                this.metricsServer.Start();

                VersionInfo.WithLabels(
                    FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(IrcClient)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(CommandBase)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(MediaWikiApi)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(ConduitClient)).Location)
                    .FileVersion,
                    Environment.Version.ToString(),
                    Environment.OSVersion.ToString(),
                    ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault())?.FrameworkDisplayName ?? "Unknown"
                    )
                .Set(1);

                this.logger.DebugFormat("Metrics server configured.");
            }
            else
            {
                this.logger.Warn("Prometheus metrics server disabled.");
            }

            this.freenodeClient.DisconnectedEvent  += this.OnDisconnect;
            this.wikimediaClient.DisconnectedEvent += this.OnDisconnect;
        }
예제 #13
0
 public NancyUserMapper(IBotUserConfiguration botUserConfiguration)
 {
     this.botUserConfiguration = botUserConfiguration;
 }