Пример #1
0
        Div explainPrecondition(APIPrecondition attribute, bool module)
        {
            string summary;
            string type = module ? "This module " : "This command ";

            if (attribute is RequireChess rc)
            {
                summary = $"must be executed by Chess user with <code>{rc._perm}</code> permission";
            }
            else if (attribute is RequireAuthentication ra)
            {
                summary = explainAuthentication(ra);
            }
            else if (attribute is RequireApprovalAttribute raa)
            {
                summary = raa._require ? "must be executed by a user who has been approved to use this website" : "does not need any approval";
            }
            else if (attribute is RequireServerName rsn)
            {
                summary = $"must be performed on the <code>{rsn.Domain}</code> domain";
            }
            else if (attribute is RequireValidHTTPAgent rvh)
            {
                summary = $"must send a User-Agent containing one of:<br/>" + listWithCode(rvh.ValidAgents);
            }
            else if (attribute is RequirePermNode rpn)
            {
                summary = $"requires all of the following permissions:</br>" + listWithCode(rpn.Nodes);
            }
            else if (attribute is RequireVerifiedAccount rva)
            {
                summary = rva._require ? "must be executed by a verified account" : "requires no verification";
            }
            else if (attribute is RequireUser ru)
            {
                summary = $"must be executed by {(Program.GetUserOrDefault(ru._user)?.Name ?? $"a specific user, of ID {ru._user}")}";
            }
            else if (attribute is RequireOwner)
            {
                summary = $"must be executed by the developer of this bot";
            }
            else if (attribute is RequireScopeAttribute rs)
            {
                return(new Div());
            }
            else
            {
                summary = attribute.GetType().Name.Replace("Attribute", "");
            }
            return(warn(type + summary));
        }
 public override bool CanChildOverride(APIPrecondition child)
 {
     return(true);
 }