Beispiel #1
0
        private async Task MessageReceived(SocketMessage message)
        {
            string content  = SanitizeContent(message.Content);
            bool   sfw      = IsSafeForWork(content);
            string response = "";

            //if (!sfw)
            //{
            //    await message.DeleteAsync();
            //}
            if (content.Substring(0, 1) == adminBot.CommandPrefix)
            {
                string command = content.Substring(1, content.Length - 1);
                response = adminBot.RunCommand(command, message);
            }
            else if (message.MentionedUsers.SingleOrDefault(x => x.Username == BotUsername) != null && message.Author.Username != BotUsername)
            {
                if (sfw)
                {
                    response = await chatBot.GetResponse(content, message.Author.Username + message.Author.Id);
                }
                else
                {
                    response = "I don't feel comfortable talking about that.";
                }
                response = message.Author.Mention + " " + response;
            }
            if (!string.IsNullOrEmpty(response))
            {
                await message.Channel.SendMessageAsync(response);
            }
        }
Beispiel #2
0
        private async Task MessageReceived(SocketMessage message)
        {
            string content  = SanitizeContent(message.Content);
            string response = "";

            if (content.Substring(0, 1) == adminBot.CommandPrefix)
            {
                string command = content.Substring(1, content.Length - 1);
                response = adminBot.RunCommand(command, message);
            }

            if (!string.IsNullOrEmpty(response))
            {
                await message.Channel.SendMessageAsync(response);
            }
        }