コード例 #1
0
        public async Task ShouldGetRoomMessagesBeforeMessageViaAPI()
        {
            var message = await _wxTeamsApi.GetMessageAsync(StaticTestingValues.ActivityTestMessage);

            var messages = await _wxTeamsApi.GetRoomMessagesBeforeMessageAsync(StaticTestingValues.JRoom, message.Id);

            messages.Should().NotBeNull();
            messages.Items.Count.Should().Be(50);
            messages.HasNextPage.Should().BeTrue();
        }
コード例 #2
0
        public async Task HandleCreatedMessage(WebhookData <Message> webhookData)
        {
            try
            {
                var person = await _wxTeamsApi.GetUserAsync(webhookData.Data.AuthorId);

                var room = await _wxTeamsApi.CreateRoomAsync("test");

                await room.DeleteAsync();

                // The Message Created event will also trigger off a message created by the bot
                // Unless you want to end up with an endless loop of messages, you have to make
                // sure you're not responding to yourself.

                // At the same time, it's probably a good idea to consider not letting your bot
                // respond to other bots at all. Only people.
                if (person.Type != PersonType.Bot)
                {
                    var message = await _wxTeamsApi.GetMessageAsync(webhookData.Data.Id);

                    var newMessage = MessageBuilder.New()
                                     .SendToRoom(message.RoomId)
                                     .WithMarkdown("**Hi!**")
                                     .Build();

                    await _wxTeamsApi.SendMessageAsync(newMessage);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #3
0
        public async Task ShouldGetWebhookDataJson_ThenFullMessage()
        {
            var json        = File.ReadAllText("Resources/WebhookPost.json");
            var webhookData = JsonConvert.DeserializeObject <WebhookData <Message> >(json);

            var fullMessage = await _wxTeamsApi.GetMessageAsync(webhookData.Data.Id);

            fullMessage.Text.Should().Be("Activity Test");
        }