예제 #1
0
        public void GenericTemplateTest()
        {
            var buttons = new List <IButton>();

            buttons.Add(new PostbackButton()
            {
                Title   = "Button 1",
                Payload = "webhook_value_1"
            });

            buttons.Add(new PostbackButton()
            {
                Title   = "Button 2",
                Payload = "webhook_value_2"
            });

            var defaultAction = new ElementAction()
            {
                Url = "https://m.me/",
            };

            var elements = new List <GenericTemplate.Element>();

            elements.Add(new GenericTemplate.Element()
            {
                Title         = "Title 1",
                Subtitle      = "Subtitle 1",
                ImageUrl      = "",
                DefaultAction = defaultAction,
                Buttons       = buttons
            });

            elements.Add(new GenericTemplate.Element()
            {
                Title    = "Title 2",
                Subtitle = "Subtitle 2",
                ImageUrl = "",
                Buttons  = buttons
            });

            var attachment = new Attachment <GenericTemplate>()
            {
                Payload = new GenericTemplate()
                {
                    Elements = elements
                }
            };

            //client.SendAttachment<LogInButton>("asd", new LogInButton());

            string result = client.SendAttachment <GenericTemplate>(UserId.ToString(), attachment).Result.Id;

            Trace.WriteLine($"Message Id: {result}");
        }
예제 #2
0
 public async Task <MessageResult> SendAttachment <T>(string userId, Attachment <T> attachment) where T : IAttachment
 {
     try
     {
         return(await sendClient.SendAttachment <T>(userId, attachment));
     }
     catch (Exception e)
     {
         Logger.LogError(e, e.Message);
         return(BaseResult.CreateFailed <MessageResult>());
     }
 }