예제 #1
0
        /// <summary>
        /// Add a mod/broadcaster quote
        /// </summary>
        /// <param name="message">Chat message from the user</param>
        /// <param name="username">User that sent the message</param>
        public async Task CmdAddQuote(string message, string username)
        {
            try
            {
                string quote = message.Substring(message.IndexOf(" ") + 1);

                await _quote.AddQuote(quote, username, _broadcasterId);

                _irc.SendPublicChatMessage($"Quote has been created @{username}");
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "CmdMod", "CmdAddQuote(string, string)", false, "!addquote");
            }
        }
예제 #2
0
        /// <summary>
        /// Add a mod/broadcaster quote
        /// </summary>
        /// <param name="chatter"></param>
        public async Task CmdAddQuote(TwitchChatter chatter)
        {
            try
            {
                string quote = chatter.Message.Substring(chatter.Message.IndexOf(" ") + 1);

                await _quote.AddQuote(quote, chatter.DisplayName, _broadcasterInstance.DatabaseId);

                _irc.SendPublicChatMessage($"Quote has been created @{chatter.DisplayName}");
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "CmdVip", "CmdAddQuote(TwitchChatter)", false, "!addquote");
            }
        }
예제 #3
0
        private async Task HandleQuoteReaction(ReactionContext context)
        {
            Quote              newQuote;
            IMessage           quotedMessage = context.Message;
            List <IAttachment> attachments   = new List <IAttachment>(quotedMessage.Attachments);

            if (attachments.Count > 0)
            {
                newQuote = new Quote(context.Channel.Name, quotedMessage.Content, quotedMessage.Author.Id, quotedMessage.Author.Username, quotedMessage.Timestamp.UtcDateTime, quotedMessage.GetMessageURL(Var.Guild.Id), attachments[0].Url);
            }
            else
            {
                newQuote = new Quote(context.Channel.Name, quotedMessage.Content, quotedMessage.Author.Id, quotedMessage.Author.Username, quotedMessage.Timestamp.UtcDateTime, quotedMessage.GetMessageURL(Var.Guild.Id));
            }
            await QuoteService.AddQuote(newQuote);

            await context.Channel.SendMessageAsync("Stored a new Quote", embed : newQuote.GetEmbed().Build());
        }
예제 #4
0
        public void given_quote_domain_object_should_save_it_to_database()
        {
            // setup
            var givenQuoteFormModel = new QuoteFormModel
            {
                AmountRequired = 15001,
                Term           = 35,
                Title          = "Mr",
                FirstName      = "ShiChang",
                LastName       = "Hou",
                Mobile         = "0434386289",
                Email          = "*****@*****.**"
            };
            var givenQuoteDomainObject = new Quote(givenQuoteFormModel, new Mock <IOptions <QuoteSetting> >().Object);
            var givenDbEntity          = givenQuoteDomainObject.ToDbEntity();

            _mockQuoteRespository.Setup(q => q.SaveQuote(It.IsAny <CalculateQuoteDbModel>())).Verifiable();

            // act
            _quoteService.AddQuote(givenQuoteDomainObject);

            // assert
            _mockQuoteRespository.Verify(q => q.SaveQuote(It.IsAny <CalculateQuoteDbModel>()), Times.Once);
        }
예제 #5
0
 public Task <Quote> OnAddQuote(AddQuoteRequest req)
 {
     return(_quoteService.AddQuote(req.Quote, req.UserId));
 }