public async Task <bool> AddReactionAsync(MessageReactionAddEventArgs e) { var reaction = new Reaction(); reaction.reaction = e.Emoji.Name; reaction.user = e.User.Username; reaction.time = DateTimeOffset.Now.ToUnixTimeMilliseconds(); var chat = utilityService.GetChat(e.Message, e.Message.MentionedUsers); var conversationName = utilityService.GetConversationName(e.Message); var metadata = utilityService.GetMetadata(e.Message); var reactionRequest = new ReactionRequest { reaction = reaction, chat = chat, type = configuration.ChatType, conversationName = conversationName, metadata = metadata }; var httpContent = utilityService.GetHttpContent(reactionRequest); var response = await client.PutAsync(configuration.ApiUrl + "/api/reactionupdate", httpContent); response.EnsureSuccessStatusCode(); var jsonResponse = await response.Content.ReadAsStringAsync(); var success = JsonConvert.DeserializeObject <bool>(jsonResponse); return(success); }
public async Task <ChatResponse> GetChatResponseAsync(MessageCreateEventArgs e) { var chat = utilityService.GetChat(e.Message, e.MentionedUsers); var conversationName = utilityService.GetConversationName(e.Message); var metadata = utilityService.GetMetadata(e.Message); var chatRequest = new ChatRequest { chat = chat, type = configuration.ChatType, conversationName = conversationName, metadata = metadata, requestTime = DateTime.Now, exclusiveTypes = configuration.ExclusiveTypes, requiredPropertyMatches = configuration.RequiredProperyMatches }; var httpContent = utilityService.GetHttpContent(chatRequest); var response = await client.PutAsync(configuration.ApiUrl + "/api/chat", httpContent); response.EnsureSuccessStatusCode(); var jsonResponse = await response.Content.ReadAsStringAsync(); var chatResponse = JsonConvert.DeserializeObject <ChatResponse>(jsonResponse); return(chatResponse); }
public async Task <bool> UpdateChatAsync(MessageCreateEventArgs e) { var chat = utilityService.GetChat(e.Message, e.MentionedUsers); var conversationName = utilityService.GetConversationName(e.Message); var metadata = utilityService.GetMetadata(e.Message); var chatRequest = new ChatRequest { chat = chat, type = configuration.ChatType, conversationName = conversationName, metadata = metadata }; var httpContent = utilityService.GetHttpContent(chatRequest); var response = await client.PutAsync(configuration.ApiUrl + "/api/chatupdate", httpContent); response.EnsureSuccessStatusCode(); var jsonResponse = await response.Content.ReadAsStringAsync(); var success = JsonConvert.DeserializeObject <bool>(jsonResponse); return(success); }