internal static string CleanChannelMentions(PublicChannel channel, string text, List <PublicChannel> channels = null) { var server = channel.Server; if (server == null) { return(text); } return(_channelRegex.Replace(text, new MatchEvaluator(e => { ulong id; if (e.Value.Substring(2, e.Value.Length - 3).TryToId(out id)) { var mentionedChannel = server.GetChannel(id); if (mentionedChannel != null && mentionedChannel.Server.Id == server.Id) { if (channels != null) { channels.Add(mentionedChannel); } return '#' + mentionedChannel.Name; } } return e.Value; //Channel not found or parse failed }))); }
public ChannelPermissions GetPermissions(PublicChannel channel) { if (channel == null) { throw new ArgumentNullException(nameof(channel)); } return(channel.GetPermissions(this)); }
public PermissionManager(PublicChannel channel, APIChannel model, int initialSize = -1) { _channel = channel; if (initialSize >= 0) { _users = new ConcurrentDictionary <ulong, Member>(2, initialSize); } Update(model); }
internal static string CleanUserMentions(PublicChannel channel, string text, List <User> users = null) { return(_userRegex.Replace(text, new MatchEvaluator(e => { ulong id; if (e.Value.Substring(2, e.Value.Length - 3).TryToId(out id)) { var user = channel.GetUser(id); if (user != null) { if (users != null) { users.Add(user); } return '@' + user.Name; } } return e.Value; //User not found or parse failed }))); }