예제 #1
0
 private void CreateTrelloCard(ChatCommand e, string listName)
 {
     try
     {
         var messageArray = CardMessageHandler(e.ArgumentsAsString);
         if (messageArray.Length == 2)
         {
             if (e.ChatMessage.IsModerator ||
                 e.ChatMessage.IsBroadcaster ||
                 e.ChatMessage.IsSubscriber ||
                 e.ChatMessage.IsVip)
             {
                 var testCard = new NewTrelloCard
                 {
                     UserName    = e.ChatMessage.DisplayName,
                     CardName    = messageArray[0],
                     Description = messageArray[1],
                     ListName    = listName
                 };
                 _trelloService.AddNewCardAsync(testCard);
             }
         }
     }
     catch (Exception ex)
     {
         _client.SendMessage(_settings.Channel,
                             $"{e.ChatMessage.DisplayName} That card wasn't created, sorry!!");
         Console.WriteLine($"Failed to write Trello card: {ex.Message}");
     }
 }
예제 #2
0
        public string AddNewCardAsync(NewTrelloCard card)
        {
            try
            {
                var list = _trelloSettings
                           .TrelloLists.FirstOrDefault(l => l.Name.ToLower() == card.ListName.ToLower());
                var listActual = _trello.Lists.WithId(list.Id);
                var board      = _trello
                                 .Boards.WithId(_trelloSettings.BoardId);

                Card trelloCard = _trello
                                  .Cards.Add(new NewCard(card.CardName, listActual));

                trelloCard.Desc = $"{card.UserName} suggests {card.Description}";

                _trello.Cards.Update(trelloCard);

                return("Your Trello card was added, thank you for your input!");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error adding card: {ex}");
                return("There was an error adding your card :-(");
            }
        }
예제 #3
0
        public void AddNewCardAsync(NewTrelloCard card)
        {
            var list = _trelloSettings
                       .TrelloLists.FirstOrDefault(l => l.Name.ToLower() == card.ListName.ToLower());
            var listActual = _trello.Lists.WithId(list.Id);
            var board      = _trello
                             .Boards.WithId(_trelloSettings.BoardId);

            Card trelloCard = _trello
                              .Cards.Add(new NewCard(card.CardName, listActual));

            trelloCard.Desc = $"{card.UserName} suggests {card.Description}";

            _trello.Cards.Update(trelloCard);
        }
 private void CreateTrelloCard(ChatCommand e, string listName)
 {
     try
     {
         if (e.ChatMessage.IsModerator ||
             e.ChatMessage.IsBroadcaster ||
             e.ChatMessage.IsSubscriber ||
             e.ChatMessage.IsVip)
         {
             var messageArray = CardMessageHandler(e.ArgumentsAsString);
             if (messageArray.Length == 2)
             {
                 var testCard = new NewTrelloCard
                 {
                     UserName    = e.ChatMessage.DisplayName,
                     CardName    = messageArray[0],
                     Description = messageArray[1],
                     ListName    = listName
                 };
                 var trelloResponse = _trelloService.AddNewCardAsync(testCard);
                 _client.SendMessage(_settings.Channel, trelloResponse);
             }
             else
             {
                 _client.SendMessage(_settings.Channel, "Hmmm, there was an error parsing your Trello card, please type !trello to see how to format a card command.");
             }
         }
         else
         {
             _client.SendMessage(_settings.Channel,
                                 "Adding a Trello card is only available to subscribers and VIPs, but thanks for getting involved!");
         }
     }
     catch (Exception ex)
     {
         _client.SendMessage(_settings.Channel,
                             $"{e.ChatMessage.DisplayName} That card wasn't created, sorry!!");
         Console.WriteLine($"Failed to write Trello card: {ex.Message}");
     }
 }