public DynamicText AddBotCmd(ISRMCommand botcmd) { var aliastext = new StringBuilder(); foreach (var alias in botcmd.Aliases) { aliastext.Append($"{alias} "); } this.Add("alias", aliastext.ToString()); aliastext.Clear(); aliastext.Append('['); aliastext.Append(botcmd.Flags & CmdFlags.TwitchLevel).ToString(); aliastext.Append(']'); this.Add("rights", aliastext.ToString()); return(this); }
public ParseState Setup(ParseState state, string parameter = null) { // These are references this._user = state._user; this._botcmd = state._botcmd; this._flags = state._flags; this._parameter = state._parameter; if (parameter != null) { this._parameter = parameter; } this._subparameter = state._subparameter; this._command = state._command; this._info = state._info; this._sort = state._sort; return(this); }
public static bool HasRights(ISRMCommand botcmd, IChatUser user, CmdFlags flags) { if (flags.HasFlag(CmdFlags.Local)) { return(true); } if (botcmd.Flags.HasFlag(CmdFlags.Disabled)) { return(false); } if (botcmd.Flags.HasFlag(CmdFlags.Everyone)) { return(true); // Not sure if this is the best approach actually, not worth thinking about right now } if (user.IsModerator & RequestBotConfig.Instance.ModFullRights) { return(true); } if (user.IsBroadcaster & botcmd.Flags.HasFlag(CmdFlags.Broadcaster)) { return(true); } if (user.IsModerator & botcmd.Flags.HasFlag(CmdFlags.Mod)) { return(true); } if (user is TwitchUser twitchUser && twitchUser.IsSubscriber & botcmd.Flags.HasFlag(CmdFlags.Sub)) { return(true); } if (user is TwitchUser twitchUser1 && twitchUser1.IsVip & botcmd.Flags.HasFlag(CmdFlags.VIP)) { return(true); } return(false); }