public IrcTell(IIrcComm irc, IMeidoComm meido) { var threading = TriggerThreading.Queue; Triggers = Trigger.Group( new Trigger("tell", Tell, threading) { Help = new TriggerHelp( "[<nick> <message>] | [count]", "Store message for nick, will be relayed when nick is active. If called with 1 or 0 arguments " + "this will read your tells, up to `count`.") }, new Trigger(Read, threading, "tell-read", "tells") { Help = new TriggerHelp( "[count]", "Read stored tell messages, up to `count` (defaults to 5).") }, new Trigger("tell-clear", Clear, threading) { Help = new TriggerHelp( "Clears all your stored tell messages.") } ); IrcHandlers = new IIrcHandler[] { new IrcHandler <IChannelMsg>(MessageHandler, threading) }; this.irc = irc; inboxes = new Inboxes(meido.DataDir); }
/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { var dbhost = Environment.GetEnvironmentVariable("DBHOST"); if (string.IsNullOrEmpty(dbhost)) { dbhost = "localhost"; } var dbname = Environment.GetEnvironmentVariable("DBNAME"); if (string.IsNullOrEmpty(dbname)) { dbname = "socomap"; } var dbuser = Environment.GetEnvironmentVariable("DBUSER"); if (string.IsNullOrEmpty(dbuser)) { dbuser = "******"; } var dbpass = Environment.GetEnvironmentVariable("DBPASS"); if (string.IsNullOrEmpty(dbpass)) { dbpass = "******"; } var connection = $"Host={dbhost}; Database={dbname}; Username={dbuser}; Password={dbpass};"; services.AddDbContext <TransmissionContext>(options => options.UseNpgsql(connection, b => b.MigrationsAssembly("Socomap"))); { var optionsBuilder = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap")); var transmissionContext = new TransmissionContext(optionsBuilder.Options); var pendingMigrations = transmissionContext.Database.GetPendingMigrations(); if (pendingMigrations != null && pendingMigrations.Any()) { transmissionContext.Database.Migrate(); } } services.AddTransient <IInboxAdapter, InboxAdapter>((IServiceProvider serviceProvider) => { var optionsBuilder = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap")); var transmissionContext = new TransmissionContext(optionsBuilder.Options); var inboxes = new Inboxes(transmissionContext); var transmissions = new Transmissions(transmissionContext, inboxes); return(new InboxAdapter(inboxes, transmissions)); }); services.AddTransient <ITransferAdapter, TransferAdapter>((IServiceProvider serviceProvider) => { var optionsBuilder = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap")); var transmissionContext = new TransmissionContext(optionsBuilder.Options); var inboxes = new Inboxes(transmissionContext); var transmissions = new Transmissions(transmissionContext, inboxes); return(new TransferAdapter(inboxes, transmissions)); } ); // Setup the database. // Add framework services. services .AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); opts.SerializerSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); }); services .AddSwaggerGen(c => { c.SwaggerDoc("0.0.1", new Info { Version = "0.0.1", Title = "SOCOMAP", Description = "SOCOMAP (ASP.NET Core 2.2)", Contact = new Contact() { Name = "Infotech GmbH", Url = "http://www.infotech.de", Email = "*****@*****.**" }, TermsOfService = "http://www.infotech.de" }); c.CustomSchemaIds(type => type.FriendlyId(true)); c.DescribeAllEnumsAsStrings(); c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); // Sets the basePath property in the Swagger document generated c.DocumentFilter <BasePathFilter>("/v1"); // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..) // Use [ValidateModelState] on Actions to actually validate it in C# as well! c.OperationFilter <GeneratePathParamsValidationFilter>(); }); }