Exemple #1
0
 public channel(dynamic data)
 {
     id          = Utility.TryGetProperty(data, "id");
     name        = Utility.TryGetProperty(data, "name");
     created     = new Slack.TimeStamp(Utility.TryGetProperty(data, "created", 0));
     creator     = Utility.TryGetProperty(data, "creator");
     is_archived = Utility.TryGetProperty(data, "is_archived", false);
     is_general  = Utility.TryGetProperty(data, "is_general", false);
     is_member   = Utility.TryGetProperty(data, "is_member", false);
     members     = new List <String>();
     if (Utility.HasProperty(data, "members"))
     {
         foreach (String strMember in data.members)
         {
             members.Add(strMember);
         }
     }
     if (Utility.HasProperty(data, "topic"))
     {
         topic.creator  = Utility.TryGetProperty(data.topic, "creator");
         topic.last_set = Utility.TryGetProperty(data.topic, "last_set", 0);
         topic.value    = Utility.TryGetProperty(data.topic, "value");
     }
     if (Utility.HasProperty(data, "purpose"))
     {
         purpose.creator  = Utility.TryGetProperty(data.purpose, "creator");
         purpose.last_set = Utility.TryGetProperty(data.purpose, "last_set", 0);
         purpose.value    = Utility.TryGetProperty(data.purpose, "value");
     }
     last_read            = new TimeStamp(Utility.TryGetProperty(data, "last_read", 0));
     unread_count         = Utility.TryGetProperty(data, "unread_count", 0);
     unread_count_display = Utility.TryGetProperty(data, "unread_count_display", 0);
 }
Exemple #2
0
 public Message(dynamic Data)
 {
     _edited = new Edited(Data.edited);
     _text   = Data.message.text;
     _ts     = new Slack.TimeStamp((String)Data.message.ts);
     _user   = Data.message.user;
 }
Exemple #3
0
 public MessageEventArgs(Slack.Client Client, dynamic Data)
 {
     _client  = Client;
     _channel = Data.channel;
     _user    = Data.user;
     _text    = Data.text;
     _ts      = new Slack.TimeStamp((String)Data.ts);
     _team    = Data.team;
 }
Exemple #4
0
 public HistoryRequestArgs(String channel, Slack.TimeStamp latest, Slack.TimeStamp oldest, Boolean inclusive, Int32 count, Boolean unreads)
 {
     this.channel   = channel;
     this.latest    = latest;
     this.oldest    = oldest;
     this.inclusive = inclusive;
     this.count     = count;
     this.unreads   = unreads;
 }
Exemple #5
0
 public DoNotDisturbUserStatus(dynamic Data)
 {
     _dnd_enabled = Data.dnd_enabled;
     if (_dnd_enabled)
     {
         _next_dnd_end_ts   = new Slack.TimeStamp(((Double)Data.next_dnd_end_ts).ToString());
         _next_dnd_start_ts = new Slack.TimeStamp(((Double)Data.next_dnd_start_ts).ToString());
     }
 }
 public Text(Slack.Client Client, dynamic Data)
 {
     _client = Client;
     _type   = Utility.TryGetProperty(Data, "type");
     _ts     = new Slack.TimeStamp(Utility.TryGetProperty(Data, "ts", 0));
     _user   = Utility.TryGetProperty(Data, "user");
     if (_user == "")
     {
         _user = Utility.TryGetProperty(Data, "username");
     }
     _text = Utility.TryGetProperty(Data, "text");
 }
Exemple #7
0
 public DoNotDisturbStatus(dynamic Data)
 {
     if (!Utility.HasProperty(Data, "dnd_status"))
     {
         return;
     }
     _dnd_enabled       = Utility.TryGetProperty(Data.dnd_status, "dnd_enabled");
     _next_dnd_end_ts   = new Slack.TimeStamp(Utility.TryGetProperty(Data.dnd_status, "next_dnd_end_ts"));
     _next_dnd_start_ts = new Slack.TimeStamp(Utility.TryGetProperty(Data.dnd_status, "dnd_start_ts"));
     _snooze_enabled    = Utility.TryGetProperty(Data.dnd_status, "snooze_enabled", false);
     _snooze_endtime    = new Slack.TimeStamp(Utility.TryGetProperty(Data.dnd_status, "snooze_endtime"));
     _snooze_remaining  = Utility.TryGetProperty(Data.dnd_status, "snooze_remaining", 0);
 }
 public MessageEditEventArgs(Slack.Client Client, dynamic Data)
 {
     _client   = Client;
     _channel  = Data.channel;
     _event_ts = Data.event_ts;
     _hidden   = Data.hidden;
     if (Utility.HasProperty(Data, "message"))
     {
         _message = new Messages.Message(Data.message);
     }
     _previous_message = new Previous_Message(Data.previous_message);
     _subtype          = Data.subtype;
     _ts = new Slack.TimeStamp((String)Data.ts);
 }
        public Boolean Delete(String channel, Slack.TimeStamp ts)
        {
            //https://api.slack.com/methods/chat.delete
            dynamic Response;

            try
            {
                String strResponse = _client.APIRequest(
                    "https://slack.com/api/chat.delete?token=" + _client.APIKey +
                    "&channel=" + System.Web.HttpUtility.UrlEncode(channel) +
                    "&ts=" + System.Web.HttpUtility.UrlEncode(ts.ToString()));
                Response = System.Web.Helpers.Json.Decode(strResponse);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not delte message.", ex);
            }
            _client.CheckForError(Response);
            return(Response.ok);
        }
Exemple #10
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;
                }
            }
        }
Exemple #11
0
 public DoNotDisturbUserStatus(dynamic Data)
 {
     _dnd_enabled       = Data.dnd_enabled;
     _next_dnd_end_ts   = new Slack.TimeStamp((String)Data.next_dnd_end_ts);
     _next_dnd_start_ts = new Slack.TimeStamp((String)Data.next_dnd_start_ts);
 }
Exemple #12
0
 public Unknown(dynamic Data)
 {
     _type = Data.type;
     _ts   = new Slack.TimeStamp((String)Data.message.ts);
 }
 public UpdateMessageResponse(dynamic Response)
 {
     channel = Utility.TryGetProperty(Response, "channel");
     ts      = new Slack.TimeStamp(Utility.TryGetProperty(Response, "ts"));
     text    = Utility.TryGetProperty(Response, "text");
 }
 public PostMessageResponse(Slack.Client client, dynamic Response)
 {
     channel = Utility.TryGetProperty(Response, "channel");
     ts      = new Slack.TimeStamp(Utility.TryGetProperty(Response, "ts"));
     message = new Slack.Messages.Text(client, Response.message);
 }
 public MetaData(dynamic Message)
 {
     this.cache_ts = new Slack.TimeStamp((Int32)Utility.TryGetProperty(Message, "cache_ts", 0));
     this.bots     = new List <RTM.bot>();
     if (Utility.HasProperty(Message, "bots"))
     {
         RTM.bot rtmBot;
         foreach (dynamic bot in Message.bots)
         {
             rtmBot         = new RTM.bot();
             rtmBot.deleted = Utility.TryGetProperty(bot, "deleted", false);
             rtmBot.id      = Utility.TryGetProperty(bot, "id", "");
             rtmBot.name    = Utility.TryGetProperty(bot, "name", "");
             this.bots.Add(rtmBot);
         }
     }
     this.cache_ts_version = Utility.TryGetProperty(Message, "cache_ts_version");
     this.cache_version    = Message.cache_version;
     this.channels         = new List <RTM.channel>();
     if (Utility.HasProperty(Message, "channels"))
     {
         RTM.channel rtmChannel;
         foreach (dynamic channel in Message.channels)
         {
             rtmChannel             = new RTM.channel(this);
             rtmChannel.created     = new Slack.TimeStamp(channel.created);
             rtmChannel.creator     = channel.creator;
             rtmChannel.has_pins    = channel.has_pins;
             rtmChannel.id          = channel.id;
             rtmChannel.is_archived = channel.is_archived;
             rtmChannel.is_channel  = channel.is_channel;
             rtmChannel.is_general  = channel.is_general;
             rtmChannel.is_member   = channel.is_member;
             rtmChannel.name        = channel.name;
             this.channels.Add(rtmChannel);
         }
     }
     this.dnd = new RTM.dnd();
     if (Utility.HasProperty(Message, "dnd"))
     {
         this.dnd.dnd_enabled       = Utility.TryGetProperty(Message.dnd, "dnd_enabled", false);
         this.dnd.next_dnd_end_ts   = new Slack.TimeStamp(Utility.TryGetProperty(Message.dnd, "next_dnd_end_ts", "0"));
         this.dnd.next_dnd_start_ts = new Slack.TimeStamp(Utility.TryGetProperty(Message.dnd, "next_dnd_start_ts", "0"));
         this.dnd.snooze_enabled    = Utility.TryGetProperty(Message.dnd, "snooze_enabled", true);
     }
     this.groups = new List <dynamic>();
     this.ims    = new List <RTM.ims>();
     if (Utility.HasProperty(Message, "ims"))
     {
         RTM.ims rtmIMS;
         foreach (dynamic ims in Message.ims)
         {
             rtmIMS                      = new RTM.ims(this);
             rtmIMS.created              = new Slack.TimeStamp(Utility.TryGetProperty(ims, "created", "0"));
             rtmIMS.has_pins             = Utility.TryGetProperty(ims, "has_pins", false);
             rtmIMS.id                   = Utility.TryGetProperty(ims, "id", "");
             rtmIMS.is_im                = Utility.TryGetProperty(ims, "is_im", false);
             rtmIMS.is_open              = Utility.TryGetProperty(ims, "is_open", false);
             rtmIMS.last_read            = Utility.TryGetProperty(ims, "last_read");
             rtmIMS.unread_count         = Utility.TryGetProperty(ims, "unread_count", 0);
             rtmIMS.unread_count_display = Utility.TryGetProperty(ims, "unread_count_display", 0);
             rtmIMS.user                 = Utility.TryGetProperty(ims, "user");
             this.ims.Add(rtmIMS);
         }
     }
     this.latest_event_ts = new Slack.TimeStamp(Utility.TryGetProperty(Message, "latest_event_ts", "0"));
     this.ok   = Utility.TryGetProperty(Message, "ok", false);
     this.self = new RTM.self();
     if (Utility.HasProperty(Message, "self"))
     {
         this.self.created         = new Slack.TimeStamp(Utility.TryGetProperty(Message.self, "created", 0));
         this.self.id              = Utility.TryGetProperty(Message.self, "id");
         this.self.manual_presence = Utility.TryGetProperty(Message.self, "manual_presence");
         this.self.name            = Utility.TryGetProperty(Message.self, "name");
         this.self.prefs           = new System.Dynamic.ExpandoObject();
     }
     this.team = new RTM.team();
     if (Utility.HasProperty(Message, "team"))
     {
         this.team.domain       = Utility.TryGetProperty(Message.team, "domain");
         this.team.email_domain = Utility.TryGetProperty(Message.team, "email_domain");
         this.team.icon         = new RTM.icon();
         if (Utility.HasProperty(Message.team, "icon"))
         {
             this.team.icon.image_102     = Utility.TryGetProperty(Message.team.icon, "image_102");
             this.team.icon.image_132     = Utility.TryGetProperty(Message.team.icon, "image_132");
             this.team.icon.image_34      = Utility.TryGetProperty(Message.team.icon, "image_34");
             this.team.icon.image_44      = Utility.TryGetProperty(Message.team.icon, "image_44");
             this.team.icon.image_68      = Utility.TryGetProperty(Message.team.icon, "image_68");
             this.team.icon.image_88      = Utility.TryGetProperty(Message.team.icon, "image_88");
             this.team.icon.image_default = Utility.TryGetProperty(Message.team.icon, "image_default", true);
         }
     }
     this.url   = Message.url;
     this.users = new List <RTM.user>();
     if (Utility.HasProperty(Message, "users"))
     {
         RTM.user rtmUser;
         foreach (dynamic user in Message.users)
         {
             rtmUser         = new RTM.user();
             rtmUser.color   = Utility.TryGetProperty(user, "color");
             rtmUser.deleted = Utility.TryGetProperty(user, "deleted", false);
             rtmUser.id      = Utility.TryGetProperty(user, "id");
             rtmUser.is_bot  = Utility.TryGetProperty(user, "is_bot", false);
             if (!rtmUser.is_bot)
             {
                 rtmUser.is_admin            = Utility.TryGetProperty(user, "is_admin", false);
                 rtmUser.is_owner            = Utility.TryGetProperty(user, "is_owner", false);
                 rtmUser.is_primary_owner    = Utility.TryGetProperty(user, "is_primary_owner", false);
                 rtmUser.is_restrictred      = Utility.TryGetProperty(user, "is_restricted", false);
                 rtmUser.is_ultra_restricted = Utility.TryGetProperty(user, "is_ultra_restricted", false);
                 rtmUser.real_name           = Utility.TryGetProperty(user, "real_name");
                 rtmUser.tz        = Utility.TryGetProperty(user, "tz");
                 rtmUser.tz_label  = Utility.TryGetProperty(user, "tz_label");
                 rtmUser.tz_offset = Utility.TryGetProperty(user, "tz_offset", 0);
             }
             rtmUser.name     = Utility.TryGetProperty(user, "name");
             rtmUser.presence = Utility.TryGetProperty(user, "presence");
             rtmUser.profile  = new Dictionary <string, string>();
             rtmUser.team_id  = Utility.TryGetProperty(user, "team_id");
             this.users.Add(rtmUser);
         }
     }
 }