예제 #1
0
 public void LogEcoMessage(ChatSent chatMessage)
 {
     Logger.DebugVerbose("Eco Message Processed:");
     Logger.DebugVerbose("Message: " + chatMessage.Message);
     Logger.DebugVerbose("Tag: " + chatMessage.Tag);
     Logger.DebugVerbose("Sender: " + chatMessage.Citizen);
 }
예제 #2
0
        public void OnMessageReceivedFromEco(ChatSent chatMessage)
        {
            LogEcoMessage(chatMessage);

            // Ignore commands and messages sent by our bot
            if (chatMessage.Citizen.Name == EcoUser.Name && !chatMessage.Message.StartsWith(DLConstants.ECHO_COMMAND_TOKEN))
            {
                return;
            }

            HandleEvent(DLEventType.EcoMessage, chatMessage);
        }
예제 #3
0
        public void Write(ChatSent message)
        {
            if (!_initialized)
            {
                return;
            }

            DateTime time      = DateTime.Now;
            int      utcOffset = TimeZoneInfo.Local.GetUtcOffset(time).Hours;

            _writer.WriteLine("[Eco] [" + DateTime.Now.ToString("yyyy-MM-dd : HH:mm", CultureInfo.InvariantCulture) + " UTC " + (utcOffset != 0 ? (utcOffset >= 0 ? "+" : "-") + utcOffset : "") + "] "
                              + $"{DiscordLink.StripTags(message.Citizen.Name) + ": " + DiscordLink.StripTags(message.Message)}");
        }
예제 #4
0
        public void OnMessageReceivedFromEco(ChatSent chatMessage)
        {
            LogEcoMessage(chatMessage);

            // Ignore commands and messages sent by our bot
            if (chatMessage.Citizen.Name == EcoUser.Name)
            {
                return;
            }
            if (chatMessage.Message.StartsWith(EchoCommandToken))
            {
                return;
            }

            UpdateIntegrations(TriggerType.EcoMessage, chatMessage);
        }
예제 #5
0
        private void ForwardMessageToDiscordChannel(DiscordLink plugin, ChatSent chatMessage, string channelNameOrId, string guildNameOrId, GlobalMentionPermission globalMentionPermission)
        {
            Logger.DebugVerbose("Sending Eco message to Discord channel " + channelNameOrId + " in guild " + guildNameOrId);
            var guild = plugin.GuildByNameOrId(guildNameOrId);

            if (guild == null)
            {
                Logger.Error("Failed to forward Eco message from user " + MessageUtil.StripTags(chatMessage.Citizen.Name) + " as no guild with the name or ID " + guildNameOrId + " exists");
                return;
            }
            var channel = guild.ChannelByNameOrId(channelNameOrId);

            if (channel == null)
            {
                Logger.Error("Failed to forward Eco message from user " + MessageUtil.StripTags(chatMessage.Citizen.Name) + " as no channel with the name or ID " + channelNameOrId + " exists in the guild " + guild.Name);
                return;
            }

            bool allowGlobalMention = (globalMentionPermission == GlobalMentionPermission.AnyUser ||
                                       globalMentionPermission == GlobalMentionPermission.Admin && chatMessage.Citizen.IsAdmin);

            _ = DiscordUtil.SendAsync(channel, MessageUtil.FormatMessageForDiscord(chatMessage.Message, channel, chatMessage.Citizen.Name, allowGlobalMention));
        }
예제 #6
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);
 }