Ejemplo n.º 1
0
        /// <summary>
        /// Send a Message to the current Chat channel.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task <bool> SendMessage(ChatMessage message)
        {
            if (IsSendingMessage)
            {
                return(false);
            }
            if (IsReloading)
            {
                WaitingMessage = message;
                ReloadEnded   -= SendMessage;
                ReloadEnded   += SendMessage;
                return(false);
            }
            IsSendingMessage = true;
            if (message.IsCommand)
            {
                CommandWorks(message);
            }
            else
            {
                ChatMessages.Add(message);
            }

            CheckLength();
            await UpdateChatMessages();

            IsSendingMessage = false;
            if (!(WaitingMessage is null))
            {
                WaitingMessage = null;
            }
            var sent = await GetMessages();

            ChatSent?.Invoke(this);
            return(sent);
        }
 protected virtual void OnChatSent(ChatSentEventArgs e)
 {
     ChatSent?.Invoke(this, e);
 }