public async Task <PostMessageResponse> PostMessage(string channelID, string message) { string url = "https://slack.com/api/chat.postMessage"; string parameters = $"token={bottoken}&channel={channelID}&text={message}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); return((PostMessageResponse)SlackResponseFactory.GetResponse(JsonResponse, "PostMessageResponse")); }
public async Task <OpenIMResponse> OpenIM(string memberID) { string url = "https://slack.com/api/im.open"; string parameters = $"token={bottoken}&user={memberID}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); return((OpenIMResponse)SlackResponseFactory.GetResponse(JsonResponse, "OpenIMResponse")); }
public async Task <UserResponse> GetUserInfo(string memberID) { string url = "https://slack.com/api/users.info"; string parameters = $"token={bottoken}&user={memberID}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); return((UserResponse)SlackResponseFactory.GetResponse(JsonResponse, "UserInfo")); }
/// <summary> /// Gets the members of a channel, starting from the given cursor /// </summary> /// <param name="channelID"></param> /// <param name="cursor"></param> /// <returns></returns> public async Task <ConversationMembersResponse> GetConversationMembers(string channelID, string cursor) { string url = "https://slack.com/api/conversations.members"; string parameters = $"token={bottoken}&channel={channelID}&cursor={cursor}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); return((ConversationMembersResponse)SlackResponseFactory.GetResponse(JsonResponse, "ConversationMembers")); }
public async Task <ChannelInfoResponse> GetConversationInfo(string channelID) { string url = "https://slack.com/api/conversations.info"; string parameters = $"token={bottoken}&channel={channelID}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); return((ChannelInfoResponse)SlackResponseFactory.GetResponse(JsonResponse, "ChannelInfo")); }
public async Task <AuthTestResponse> SendAuthMessage() { string url = "https://slack.com/api/auth.test"; string parameters = $"token={bottoken}"; var JsonResponse = await _webclient.GetStringAsync(CreateUrl(url, parameters)); var obj = (AuthTestResponse)SlackResponseFactory.GetResponse(JsonResponse, "AuthTest"); return(obj); }
public void TestMethod1() { var s = SlackResponseFactory.CreateWhereIsResponse("Robson", "Vancouver Office", new Uri("https://slack-whereis.s3.ca-central-1.amazonaws.com/maps/saturna.png"), "Meeting Room", UseStatus.Available, "Available until 5:00 PM", floor: "16th Floor"); var j = JsonConvert.SerializeObject(s); ExchangeProvider p = new ExchangeProvider(new ExchangeConfig() { Server = "https://exchange.absolute.com/ews/exchange.asmx", Domain = "absolute.com", Username = "******", Password = "******" }); bool isAvailable = p.GetAvailability("*****@*****.**", out string details); }
private Func <CancellationToken, Task> GetTaskForSearch(string searchText, Uri callbackEndpoint, IServiceScopeFactory scopeFactory) { Func <CancellationToken, Task> myFunc = (cancellationToken) => { using (var scope = scopeFactory.CreateScope()) { var locationRepository = scope.ServiceProvider.GetService <ILocationRepository>(); var httpClientFactory = scope.ServiceProvider.GetService <IHttpClientFactory>(); Console.WriteLine($"Starting search task for {searchText}"); var locations = locationRepository.GetLocationByName(searchText); if (!locations.Any()) { locations = locationRepository.GetLocationByTag(searchText); if (!locations.Any()) { SlackCallbackHelper.PostCallback(callbackEndpoint, httpClientFactory, $"I couldn't find {searchText}"); return(new Task(() => { })); } } SimpleSlackBlockResponse r = new SimpleSlackBlockResponse(); r.AddBlock(new SectionBlock() { Text = new PlainSectionBlockText("I found the following:", true) }); foreach (var location in locations) { bool available = false; string availabilityDetails = " "; if (location != null) { string locationType = "Other"; switch (location) { case MeetingRoom meetingRoom: locationType = "Meeting Room"; if (meetingRoom.EmailAddress != null) { try { available = _exchangeProvider.GetAvailability(meetingRoom.EmailAddress, out availabilityDetails); } catch (Exception ex) { _logger.LogError(ex, "Unable to obtain data from Exchange provider!"); } } break; case Employee employee: locationType = "Employee"; if (employee.EmailAddress != null) { try { available = _exchangeProvider.GetAvailability(employee.EmailAddress, out availabilityDetails); } catch (Exception ex) { _logger.LogError(ex, "Unable to obtain data from Exchange provider!"); } } break; case Department department: locationType = "Department"; break; default: locationType = location.GetType().ToString(); break; } var s = SlackResponseFactory.CreateWhereIsResponse(location.Name, location.Office, location.MapImageUrl == null ? null : new Uri(location.MapImageUrl), locationType, availabilityDetails == " " ? UseStatus.None : (available ? UseStatus.Available : UseStatus.InUse), availabilityDetails, floor: location.Floor, thumbUrl: string.IsNullOrEmpty(location.LocationImageUrl) ? null : new Uri(location.LocationImageUrl)); //var s = SlackResponseFactory.CreateWhereIsResponse(location); r.Append(s); } } r.AddBlock(new DividerBlock()).AddBlock(new ContextBlock().AddElement(new MarkdownContextElement("For any questions or issues, contact <@Henry>"))); SlackCallbackHelper.PostCallback(callbackEndpoint, httpClientFactory, r); return(new Task(() => { })); } }; return(myFunc); }