public static SlackTeam FromData(dynamic data, SlackBotApi api) { var team = new SlackTeam(api) { Id = data.team.Value <string>("id"), Name = data.team.Value <string>("name"), Domain = data.team.Value <string>("domain"), BotUser = new SlackUser() { Id = data.self.Value <string>("id"), Name = data.self.Value <string>("name") } }; foreach (var u in data.users) { if (!u.Value <bool>("deleted")) { team.Users.Add(new SlackUser(api) { Id = u.Value <string>("id"), Name = u.Value <string>("name") }); } } foreach (var c in data.channels) { if (c == null) { continue; } var channel = new SlackChannel(api) { Id = c.Value <string>("id"), Name = c.Value <string>("name"), Purpose = c["purpose"]?.Value <string>("value"), Topic = c["topic"]?.Value <string>("value"), Team = team }; if (c["members"] != null) { foreach (var u in c.members) { var user = team.Users.FirstOrDefault(x => x.Id == u.ToString()); if (user != null) { channel.Members.Add(user); } } } team.Channels.Add(channel); } return(team); }
public SlackMessage(SlackBotApi api, string id, string text, SlackChannel channel, SlackUser user, DateTime?timestamp = null, params SlackAttachment[] attachments) { SetApi(api); Id = id; Text = text; Channel = channel; User = user; Timestamp = timestamp ?? DateTime.UtcNow; Attachments = new List <SlackAttachment>(attachments); }
public async Task <SlackEphemeral> SendEphemeralAsync(SlackChannel channel, string text, params SlackAttachment[] attachments) { return(await Api.SendEphemeralAsync(this, channel, text, attachments)); }