Exemplo n.º 1
0
        void AddMessage(SlackAPI.Message entry)
        {
            if (entry.user == null || entry.text == null)
            {
                return;
            }

            User   u        = adapter.GetUserInfo(entry.user);
            string username = u != null ? u.name : "Unknown";

            if (lastMessage != null && lastMessage.OwnerUsername.Equals(username) && entry.ts.Subtract(lastMessage.lastTimeStamp) < TimeSpan.FromMinutes(5))
            {
                lastMessage.AppendMessage(entry.text, entry.ts);
            }
            else
            {
                int lastY = 0;
                if (lastMessage != null)
                {
                    lastY = lastMessage.Bottom;
                }

                lastMessage          = new MessageEntry(this, username, adapter.GetUserImage(entry.user), entry.text, entry.ts, messages, timestamps);
                lastMessage.Location = new Point(0, lastY + 10);
                lastMessage.Width    = chatContent.Size.Width - 16; //TODO: Replace this with anchors and widths in the child panel.
                chatContent.Controls.Add(lastMessage);
            }

            chatContent.AutoScrollPosition = new Point(lastMessage.Left, chatContent.DisplayRectangle.Height);
        }
Exemplo n.º 2
0
        public static ChannelMessage ToChannelMessage(this SlackAPI.Message message)
        {
            var result = new ChannelMessage();

            result.Time      = message.ts;
            result.User      = message.user;
            result.Username  = message.username;
            result.Text      = message.text;
            result.ChannelId = message.channel;
            result.IsStarred = message.is_starred;

            return(result);
        }
Exemplo n.º 3
0
 private bool IsRegularMessage(Message message)
 {
     return this.IsRegularMessage(message.user, message.subtype);
 }