-
Notifications
You must be signed in to change notification settings - Fork 3
/
SlackQueryFollowup.cs
57 lines (49 loc) · 1.83 KB
/
SlackQueryFollowup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Nysgjerrig
{
class SlackQueryFollowup : SlackBase
{
[FunctionName("Followup")]
public async Task<IActionResult> Followup([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
try
{
log.LogInformation($"Request method={req.Method} https={req.IsHttps} content-type={req.ContentType}");
var channelMessages = await GetChannelMessages(limit: 1);
var lastMessage = channelMessages.Last();
if (lastMessage.User == SlackBotId)
{
await ReactToMessage(lastMessage.Ts, "question");
}
else
{
await ReactToMessage(lastMessage.Ts);
}
return new OkObjectResult(null);
}
catch (Exception ex)
{
log.LogInformation($"{ex.Message} \n{ex.StackTrace}");
throw;
}
//TODO: Find a way to fetch the previous question to send an appropriate answer/reminder
//var fakeMembers = new List<ChatMember> { new ChatMember { Id = ""} };
//var chats = GetChats(fakeMembers);
//await SendMessage(selectedChat, commandRequest);
/*
* optional:
* check for replies after two minutes
* - if none, remind
* - if only selected user, send randomized positive response
* - if other users responded as well, react
*/
}
}
}