public Slack.Channels.HistoryResponse History(Slack.Channels.HistoryRequestArgs args)
        {
            //https://api.slack.com/methods/channels.history
            dynamic Response;

            try
            {
                String strGet =
                    "token=" + _client.APIKey +
                    "&channel=" + System.Web.HttpUtility.UrlEncode(args.channel) +
                    "&latest=" + args.latest.ToString() +
                    "&oldest=" + args.oldest.ToString() +
                    "&inclusive=" + ((args.inclusive) ? 1 : 0) +
                    "&count=" + args.count +
                    "&unreads=" + ((args.unreads) ? 1 : 0);
                String strResponse = _client.APIRequest("https://slack.com/api/channels.history?" + strGet);
                Response = System.Web.Helpers.Json.Decode(strResponse);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not create channel.", ex);
            }
            _client.CheckForError(Response);
            return(new Slack.Channels.HistoryResponse(_client, args, Response));
        }
Exemple #2
0
        public HistoryResponse(Slack.Client Client, Slack.Channels.HistoryRequestArgs args, dynamic Response)
        {
            _client   = Client;
            _args     = args;
            _latest   = new Slack.TimeStamp(Utility.TryGetProperty(Response, "latest", 0).ToString());
            _hasMore  = Utility.TryGetProperty(Response, "has_more", false);
            _messages = new List <Messages.IMessage>();
            String strType;

            foreach (dynamic message in Response.messages)
            {
                strType = message.type;
                switch (strType)
                {
                case "message":
                    _messages.Add(new Slack.Messages.Text(_client, message));
                    break;

                default:
                    _messages.Add(new Slack.Messages.Unknown(message));
                    break;
                }
            }
        }