public static async Task CheckBlockedDomains(string content, SocketCommandContext context) { List <BlockedDomainDTO> blockedDomains = BlockedDomains.Instance.Domains(); foreach (BlockedDomainDTO domain in blockedDomains) { if (content.Contains(domain.Url)) { if (domain.Ban == true) { // exclude Mods from the bans if (IsMod(context.User)) { return; } // Ban the user string reason = string.Format(Constants.BAN_MESSAGE, context.User.Username, domain.Reason); await context.Guild.AddBanAsync(context.User, 1, reason, null); // post a message in the channel about the permanent ban await context.Message.Channel.SendMessageAsync("BAM!!! " + reason); // send a message to #botspam channel as well string detailedMessage = "Woohoo! " + reason + " Posted message: " + content; await HAChannels.ModLogChannel(context).SendMessageAsync(detailedMessage, false, null); } else { string maskedUrl = domain.Url.Replace(".", "_dot_"); // DM the message to the user, so that they can copy/paste without domain name/links // save time, so that tey don't have to re-type the whole message :) var dmChannel = await context.User.GetOrCreateDMChannelAsync(); await dmChannel.SendMessageAsync(string.Format(Constants.USER_MESSAGE_BLOCKED_URL, maskedUrl, domain.Reason, content)); // delete the message await context.Message.DeleteAsync(); // show message string msg = string.Format(Constants.ERROR_BLOCKED_URL, context.User.Mention, maskedUrl, domain.Reason); await context.Message.Channel.SendMessageAsync(msg); } } } }
private static async Task KickWarningMessage(SocketCommandContext context) { var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nHello there!"); sb.Append("\n"); sb.Append("You are on the verge of getting kicked out of the server for not following the rules. You've been issued 3 warnings already, and you only have 2 left."); sb.Append("\n"); sb.Append("You have repeatedly violated the rules that we all take very seriously. Please pay attention to the rules!"); sb.Append("\n"); sb.Append("Please reach out to any of the mods to get you off of the naughtly list. If these violations continue, you will be kicked out of the server."); sb.Append("\n"); sb.Append("Thank you!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("User " + context.User.Mention + " was given a warning for violating rules for 3 consecutive times!", false, null); }
private static async Task KickWarningMessage(SocketCommandContext context) { var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nOlá!"); sb.Append("\n"); sb.Append("Tu estás prestes a ser banido do servidor, por não estares a cumprir as regras. Já foste avisado 3 vezes, restam-te duas."); sb.Append("\n"); sb.Append("Já violaste muitas vezes as regras do servidor. Por favor lê as regras!"); sb.Append("\n"); sb.Append("Por favor entra em contacto como o @manager. Se continuares a infrigir as regras serás banido permanetemente."); sb.Append("\n"); sb.Append("Obrigado!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("User " + context.User.Mention + " was given a warning for violating rules for 3 consecutive times!", false, null); }
private static async Task KickWarningMessage(SocketCommandContext context) { var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nCaro utilizador,"); sb.Append("\n"); sb.Append("Estás perto de ser expulso do nosso servidor de Discord por não cumprires as Regras. Já foste avisado por três (3) vezes, mais duas (2) e serás expulso."); sb.Append("\n"); sb.Append("Apesar dos avisos violaste repetidamente as regras, as quais foram criadas para o bom funcionamento do servidor e respeito entre todos os utilizadores!"); sb.Append("\n"); sb.Append("Podes ler as nossas regras no canal #regras-de-utilização"); sb.Append("\n"); sb.Append("Por favor contacta um moderador ou administrador. Se a violação às regras continuar serás expulso do servidor."); sb.Append("\n"); sb.Append("Obrigado!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("O utilizador " + context.User.Mention + " foi avisado por violar as regras por três (3) vezes consecutivas!", false, null); }
private static async Task KickMessage(SocketUserMessage message, SocketCommandContext context) { // Send a Direct Message to the User var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nHello, there!"); sb.Append("\n\n"); sb.Append("We got a bit of a problem here. We have some ground rules that we **really** like you to follow."); sb.Append("\n"); sb.Append("Please make sure you pay **EXTRA** attention to the welcome notes and read descriptions of each channel carefully."); sb.Append("\n\n"); sb.Append("You got kicked out of the Discord server for posting code that is more than 15 lines **FOR MORE THAN 5 TIMES**."); sb.Append("\n\n"); sb.Append("We would love to work with you to help you provide the support you need. For that, we all have to follow the rules and keep it civil."); sb.Append("\n"); sb.Append("Once you had the chance to read and understood the rules, you can simply log back and meet with the awesome community."); sb.Append("\n"); sb.Append("To join the server, click on the link again"); sb.Append("\n"); sb.Append("https://discord.gg/c5DvZ4e"); sb.Append("\n\n"); sb.Append("Thank you, and hope to see you again!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // kick the user await((SocketGuildUser)message.Author).KickAsync("Posted code walls for more than 5 times.", null); await message.Channel.SendMessageAsync("User " + context.User.Mention + " got kicked out because of posting too many codewalls!"); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("User " + context.User.Mention + " got kicked out for violating rules for more than 5 times!", false, null); // finally clear the violations, so that the user can start fresh ViolationsManager.TheViolationsManager.ClearViolationsForUser(context.User.Id); }
private static async Task KickMessage(SocketUserMessage message, SocketCommandContext context) { // Send a Direct Message to the User var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nCaro utilizador,"); sb.Append("\n\n"); sb.Append("Temos um problema. Existem regras que devem ser seguidas e que gostariamos **mesmo** que as seguisses."); sb.Append("\n"); sb.Append("Certifica-te que **leste e compreendeste** as regras de utilização que estão descritas em #regras-de-utilização e as descrições de cada canal."); sb.Append("\n\n"); sb.Append("Foste expulso do nosso servidor do Discord por publicares código com mais de 15 linhas por **MAIS DE 5 VEZES**."); sb.Append("\n\n"); sb.Append("Gostariamos de te poder ajudar e dar o suporte que necessitas mas para isso as regras devem ser cumpridas"); sb.Append("\n"); sb.Append("Quando leres e compreenderes as regras, podes simplesmente fazer login de novo e voltares a estar connosco."); sb.Append("\n"); sb.Append("Para te juntares de novo ao nosso servidor, clica no link abaixo."); sb.Append("\n"); sb.Append("https://discord.gg/Mh9mTEA"); sb.Append("\n\n"); sb.Append("Obrigado, e esperamos ver-te de novo em breve!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // kick the user await((SocketGuildUser)message.Author).KickAsync("Publicação de mensagens/código com mais de 15 linhas por mais de cinco (5) vezes.", null); await message.Channel.SendMessageAsync("User " + context.User.Mention + " got kicked out because of posting too many codewalls!"); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("O utilizador " + context.User.Mention + " foi expulso por violar as regras mais de cinco (5) vezes!", false, null); // finally clear the violations, so that the user can start fresh ViolationsManager.TheViolationsManager.ClearViolationsForUser(context.User.Id); }
private static async Task KickMessage(SocketUserMessage message, SocketCommandContext context) { // Send a Direct Message to the User var dmChannel = await context.User.GetOrCreateDMChannelAsync(); StringBuilder sb = new StringBuilder(); sb.Append("\n\nOlá!"); sb.Append("\n\n"); sb.Append("Temos um problema aqui temos regras que gostavamos que **tu** leias."); sb.Append("\n"); sb.Append("Por favor lê as descrições de cada canal"); sb.Append("\n\n"); sb.Append("Foste kikado do canal por postares código com mais de 15 linhas **Tens mais 5 tentativas**."); sb.Append("\n\n"); sb.Append("Gostariamos muito de te dar o suporte que precisas. Para isso, lê as regras e sê cívico"); sb.Append("\n"); sb.Append("Uma vez que leste e compreendeste as regras, podes voltar a entrar na nossa comunidade."); sb.Append("\n"); sb.Append("Para entrar no servidor, clica no link de novo"); sb.Append("\n"); sb.Append("https://discord.gg/Mh9mTEA"); sb.Append("\n\n"); sb.Append("Obrigado, esperamos te ver em breve!\n"); await dmChannel.SendMessageAsync(sb.ToString()); // kick the user await((SocketGuildUser)message.Author).KickAsync("Postas te o código mais de 5 vezes.", null); await message.Channel.SendMessageAsync("User " + context.User.Mention + " Foste kikado por postares o código de forma errada muitas vezes!"); // send a message to #botspam channel as well await HAChannels.ModLogChannel(context).SendMessageAsync("User " + context.User.Mention + "Foste kickado por não respeitares as regras por mais de 5 vezes", false, null); // finally clear the violations, so that the user can start fresh ViolationsManager.TheViolationsManager.ClearViolationsForUser(context.User.Id); }
public static async Task ProcessSubscriptions(SocketUserMessage message, SocketCommandContext context, SocketGuildChannel channel) { // only interested in processing incoming messages to the #github channel if (null == channel || channel.Name != "github" || message.Embeds.Count <= 0) { return; } // #github channel contains messages from many different sources. foreach (Embed e in message.Embeds) { List <string> uniqueTags = SubscriptionManager.TheSubscriptionManager.GetDistinctTags(); List <SubscribeDTO> uniqueUsers = new List <SubscribeDTO>(8); List <string> matchedTags = new List <string>(32); List <string> matchedLocations = new List <string>(32); // first get all the unique tags across all users and check if any of the tags match // if there is a match, keep a list of those tags foreach (string tag in uniqueTags) { if (e.Description.ToLower().Contains(tag)) { matchedLocations.Add("Description"); matchedTags.Add(tag); } if (e.Url.ToLower().Contains(tag)) { matchedLocations.Add("Url"); matchedTags.Add(tag); } if (e.Author.ToString().ToLower().Contains(tag)) { matchedLocations.Add("Author"); matchedTags.Add(tag); } if (e.Title.ToLower().Contains(tag)) { matchedLocations.Add("Title"); matchedTags.Add(tag); } } // filter out any duplicates matchedTags = matchedTags.Distinct().ToList(); matchedLocations = matchedLocations.Distinct().ToList(); // if there are matched tags, get unique list of users that are interested in those tags if (matchedTags.Count > 0) { foreach (string tag in matchedTags) { uniqueUsers.AddRange(SubscriptionManager.TheSubscriptionManager.GetSubscribersByTag(tag)); } // now that we have list of users that are interested in the tag, and the tags match in description/author name/title // send the url of the message to each of the subscriber using a DM foreach (SubscribeDTO usr in uniqueUsers.Distinct().ToList()) { string msg = string.Format("Subscription Alert: Found '{0}' in the '{1}' of the PR/Issue: {2}", GetListAsCommaSeparated(matchedTags), GetListAsCommaSeparated(matchedLocations), e.Url); var dmChannel = await HAChannels.GetUsersDMChannel(context, usr.Id); await dmChannel.SendMessageAsync(msg); } } } }