Example #1
0
        public static async Task FilterBotMessages(SocketUserMessage message,
                                                   SocketCommandContext context,
                                                   SocketGuildChannel channel)
        {
            // A list of channels to monitor
            List <string> channelfilter = new List <string>()
            {
                "github", "circleci", "netlify"
            };

            if (null == channel || !channelfilter.Contains(channel.Name) || message.Embeds.Count <= 0)
            {
                return;
            }

            // A list of bots to monitor
            List <string> botfilter = new List <string>()
            {
                "houndci-bot"
            };

            // check if the sender is a known bot before deleting.
            foreach (Embed e in message.Embeds)
            {
                EmbedAuthor author = (EmbedAuthor)e.Author;
                if (botfilter.Contains(author.ToString()) || author.ToString().EndsWith("[bot]"))
                {
                    await context.Message.DeleteAsync();
                }
            }
        }
Example #2
0
        public static async Task HandleHoundCIMessages(SocketUserMessage message,
                                                       SocketCommandContext context,
                                                       SocketGuildChannel channel)
        {
            if (null == channel || channel.Name != "github" || message.Embeds.Count <= 0)
            {
                return;
            }

            bool purgeHoundBotMsgs = AppSettingsUtil.AppSettingsBool("deleteHoundBotMsgs",
                                                                     false, false);

            if (!purgeHoundBotMsgs)
            {
                return;
            }

            // #github channel contains messages from many different sources.
            // check if the sender is 'houndci-bot' before deleting.
            foreach (Embed e in message.Embeds)
            {
                EmbedAuthor author = (EmbedAuthor)e.Author;
                if (author.ToString() == "houndci-bot")
                {
                    //logger.InfoFormat("Deleting the houndci-bot message: {0} => {1}: {2}",
                    //                   e.Url, e.Title, e.Description);
                    await context.Message.DeleteAsync();
                }
            }
        }