Example #1
0
        void IInitializableModule.Initialize()
        {
            StreamModule streammodule = context.GetModule <StreamModule>();

            notificationwindow = context.GetModule <NotificationModule>();
            usermodule         = context.GetModule <UserModule>();
            imagemodule        = context.GetModule <ImageCacheModule>();

            streammodule.NewFollower += information => notificationwindow.ShowNotification(
                new MessageBuilder().Text("New Follower").BuildMessage(),
                new MessageBuilder()
                .User(usermodule.GetExistingUser(information.Service, information.Username), u => imagemodule.AddImage(u.Avatar))
                .Text(" started to follow.")
                .BuildMessage()
                );

            streammodule.NewSubscriber += information => notificationwindow.ShowNotification(
                new MessageBuilder().Text("New Subscriber").BuildMessage(),
                new MessageBuilder()
                .User(usermodule.GetExistingUser(information.Service, information.Username), u => imagemodule.AddImage(u.Avatar))
                .Text(" subscribed with ")
                .Text(information.PlanName, StreamColors.Option, FontWeight.Bold)
                .Text(" to this channel.")
                .BuildMessage()
                );

            streammodule.Hosted += information => notificationwindow.ShowNotification(
                new MessageBuilder().Text("New Host").BuildMessage(),
                information.Viewers > 0 ?
                new MessageBuilder().User(usermodule.GetExistingUser(information.Service, information.Channel), u => imagemodule.AddImage(u.Avatar)).Text(" is hosting this channel to ").Text(information.Viewers.ToString(), StreamColors.Option, FontWeight.Bold).Text(" viewers.").BuildMessage() :
                new MessageBuilder().User(usermodule.GetExistingUser(information.Service, information.Channel), u => imagemodule.AddImage(u.Avatar)).Text(" is hosting this channel.").BuildMessage()
                );

            streammodule.Raid += OnRaid;
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            NotificationModule.ConfigureServices(services);
        }
Example #3
0
        protected override async Task Init()
        {
            notificationModule = await GetModuleAsync <NotificationModule>();

            SeatLogin login = new SeatLogin("Prople Dudlestreis", "VIYcOHK2jzJ7V54GxxKOJ59jUYezgXe8");

            SeAT = API.Create("https://seat.bovrilbloodminers.org/docs/api-docs.json", login, WebClient, ApiConfig);
        }
Example #4
0
        public static IServiceCollection AddNotificationsModule(this IServiceCollection services, Module.Configurations configurations,
                                                                Module.EventsToSubscribe eventsToSubscribe, IEventBus eventBus)
        {
            var module = new NotificationModule(configurations, eventsToSubscribe, eventBus);

            services.AddSingleton(module);

            return(services);
        }
        /// <summary>
        /// creates a new <see cref="PollNotificationGenerator"/>
        /// </summary>
        /// <param name="module">access to poll module</param>
        /// <param name="notifications">access to notification module</param>
        public PollNotificationGenerator(PollModule module, NotificationModule notifications)
        {
            this.notifications = notifications;

            module.PollCreated   += OnPollCreated;
            module.PollRemoved   += OnPollRemoved;
            module.PollCleared   += OnPollCleared;
            module.OptionAdded   += OnOptionAdded;
            module.OptionRemoved += OnOptionRemoved;
            module.OptionReset   += OnOptionReset;
        }
        public async Task SubmitNotificationShouldSucceedWhenAllIsWell()
        {
            var sender = Substitute.For <IEmailSender>();
            var module = new NotificationModule(Substitute.For <ILogger <NotificationModule> >(), sender);

            var fixture = new Fixture();

            var model = fixture.Build <NotificationRequestModel>()
                        .Create();

            var result = await module.SubmitEmailNotification(model);

            result.Status.Should().Be(RequestStatus.Success);
            sender.Received(1).SendEmailAsync(Arg.Any <NotificationRequestModel>(), Arg.Any <NotificationType>());
        }
Example #7
0
        protected override void OnStart(string[] args)
        {
            try
            {
                var timer = Settings.AppSettings.DeleteTimer;

                _fileProber.Listen();
                _fileProber.DeleteTorrents(milliseconds: timer);
                _fileProber.DeleteExtraFiles(millseconds: timer);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex.Message);
                NotificationModule.SendEmail("Application exception " + ex.Message);
            }
        }
        public async Task SubmitNotificationShouldBeCriticalWhenSenderFailed()
        {
            var sender = Substitute.For <IEmailSender>();
            var module = new NotificationModule(Substitute.For <ILogger <NotificationModule> >(), sender);

            var fixture = new Fixture();

            var model = fixture.Build <NotificationRequestModel>()
                        .Create();

            sender.SendEmailAsync(Arg.Any <NotificationRequestModel>(), Arg.Any <NotificationType>()).Returns(c =>
            {
                throw new Exception("Email exception");
            });
            var result = await module.SubmitEmailNotification(model);

            result.Status.Should().Be(RequestStatus.Exception);
            result.FriendlyMessage.Should().Be("Oops. That was not suppose to happen");
            result.SystemMessage.Should().Be("Email exception");
            sender.Received(1).SendEmailAsync(Arg.Any <NotificationRequestModel>(), Arg.Any <NotificationType>());
        }
Example #9
0
        public void Push(NotificationModule notification)
        {
            //foreach (var user in notification.Receiver)
            //{
            //    var db = new DbHelper ();
            //    var post = db.QueryDynamicList ("select ifnull(Phone,'') as Phone from account_customer where UserAccount = '" + user + "'");
            //    if (post.Count > 0)
            //    {
            //        string Phone = post.ToArray () [0].Phone;
            //        if (Phone != null && Phone != "")
            //        {
            //            if (notification.Sender != "" && notification.Title != "" && notification.Message != "")
            //            {
            //                SendSMSVoice (Phone, notification.Sender, notification.Title, notification.Message, notification.Voicebo);
            //            }
            //            else
            //            {

            //            }
            //        }
            //    }
            //}
        }
Example #10
0
 /// <summary>
 /// </summary>
 /// <param name="notification"></param>
 /// <returns></returns>
 public string Push2(NotificationModule notification)
 {
     return("");
 }
 public NotificationService(NotificationModule.Contracts.INotificationService notificationService)
 {
     this.notificationService = notificationService;
 }
Example #12
0
        protected override async Task Init()
        {
            notificationModule = await GetModuleAsync <NotificationModule>();

            moonParser = new MoonParser();
        }
Example #13
0
 protected override void OnStop()
 {
     _fileProber.Dispose();
     NotificationModule.SendEmail("Application stopping");
 }