private async Task <ProxyMatch> FindCurrentProxy(SocketMessage msg, BotUser botUser, ITextChannel channel) { log.Debug($"Looking for current proxy for {msg.Author} in {channel.Guild.Name}:{channel.Name}"); var proxy = await proxyBuilder.GetCurrentProxy(botUser, channel.Id); return(proxy != null ? ProxyMatch.GetMatch(proxy, msg, msg.Content) : ProxyMatch.NoMatch); }
private ProxyMatch FindProxyForMessage(SocketMessage msg, BotUser botUser) { var md = ProxyMatch.NoMatch; var validProxies = botUser.Proxies .Where(p => p.IsForChannel(msg)) .OrderBy(p => p.IsGlobal); foreach (var p in validProxies) { var proxyMatch = regexCache.GetRegexFor(p).Match(msg.Content); if (proxyMatch.Success) { md = ProxyMatch.GetMatch(p, msg, proxyMatch.Groups["text"].Value); } } return(md); }