xxxxxxx="https://cute521.cn/"
--官网

xxxxxxx_Notice="api.php?api=notice"
--接口名称[获取公告]

xxxxxxx_to_configure="api.php?api=ini"
--接口名称[应用配置]

xxxxxxx_file="api.php?api=getfile"
--接口名称[获取文件外链]

xxxxxxx_APPID="10665"
--APPID

xxxxxxx_APPKEY="Q7Fq3iOf7IP93Vmm"
--APPKEY

xxxxxxx_RC4_key="XEBBfcJsnd810665"
--RC4 加密秘钥

xxxbanb="1.0"
--版本



uio=gg.makeRequest(xxxxxxx).content
--检查是否 用户被拉黑
if uio:match("<title>(.-)</title>")=="检测中" then
gg.alert("当前请求状态异常，需要手动验证....","结束")--对话框
print("\n需要你手动在浏览器打开官网进行验证: \n"..xxxxxxx)--打印
os.exit()
end

ZZMathBit = {}

function ZZMathBit.__xorBit(left, right)
    return (left + right) == 1 and 1 or 0
end

function ZZMathBit.__base(left, right, op)
    if left < right then
        left, right = right, left
    end
    local res = 0
    local shift = 1
    while left ~= 0 do
        local ra = left % 2
        local rb = right % 2
        res = shift * op(ra,rb) + res
        shift = shift * 2
        left = math.modf( left / 2)
        right = math.modf( right / 2)
    end
    return res
end
function ZZMathBit.xorOp(left, right)
    return ZZMathBit.__base(left, right, ZZMathBit.__xorBit)
end
function RC4(text,key)
    local function KSA(key)
        local keyLen = string.len(key)
        local schedule = {}
        local keyByte = {}
        for i = 0, 255 do
            schedule[i] = i
        end
        for i = 1, keyLen do
            keyByte[i - 1] = string.byte(key, i, i)
        end
        local j = 0
        for i = 0, 255 do
            j = (j + schedule[i] + keyByte[ i % keyLen]) % 256
            schedule[i], schedule[j] = schedule[j], schedule[i]
        end
        return schedule
    end
    local function PRGA(schedule, textLen)
        local i = 0
        local j = 0
        local k = {}
        for n = 1, textLen do
            i = (i + 1) % 256
            j = (j + schedule[i]) % 256
            schedule[i], schedule[j] = schedule[j], schedule[i]
            k[n] = schedule[(schedule[i] + schedule[j]) % 256]
        end
        return k
    end
    local function output(schedule, text)
        local len = string.len(text)
        local c = nil
        local res = {}
        for i = 1, len do
            c = string.byte(text, i,i)
            res[i] = string.char(ZZMathBit.xorOp(schedule[i], c))
        end
        return table.concat(res)
    end
    local textLen = string.len(text)
    local schedule = KSA(key)
    local k = PRGA(schedule, textLen)
    return output(k, text)
end
function eyccd(str)
  str = tostring(str)
    str=str:gsub("[%s%p]",""):upper()
    local index=1
    local ret=""
    for index=1,str:len(),2 do
      ret=ret..string.char(tonumber(str:sub(index,index+1),16))
    end
    return ret
end

function POST(path,body)
 local c=gg.makeRequest(path,nil,body).content 
 return c 
end

update=POST(xxxxxxx.."/".. xxxxxxx_to_configure.."&app=".. xxxxxxx_APPID,"")
update=RC4(eyccd(update),xxxxxxx_RC4_key)
code=update:match('"code":(.-),"')--获取状态码
xxxxbanben=update:match('"version":"(.-)",')--获取版本号
xxxxgxnr=update:match('app_update_show":"(.-)",')--更新内容
xxxxlianjie=update:match('app_update_url":"(.-)","app_update_must')--更新链接
msg=update:match('"msg":"(.-)",')
if code~="200" then
gg.alert(msg)
os.exit()
end

if xxxxbanben==xxxbanb then
gg.toast("当前已是最新版本")--提示
else
gg.alert("发现新版本\n最新版本："..xxxxbanben.."\n更新内容："..xxxxgxnr.."\n下载地址："..xxxxlianjie,"确定")
print("下载地址:\n"..xxxxlianjie)--打印
os.exit()
end


function oqvqo()
rq=os.date("\n%Y".."年".."%m".."月".."%d".."日".." ".."%H".."时".."%M".."分".."%S".."秒")

Notice=POST(xxxxxxx.."/"..xxxxxxx_Notice.."&app="..xxxxxxx_APPID,"")
Notice=RC4(eyccd(Notice),xxxxxxx_RC4_key)

function JSON(b)
b=string.gsub(b,"s:","+!")
b=string.gsub(b,':',']=')
b=string.gsub(b,"{","{[")
b=string.gsub(b,',"',',["')
b=string.gsub(b,"+!","s:")
fuil=load("b3="..b)

if fuil==nil then
gg.alert("提示:\nkey 错误  请联系作者")--对话框
os.exit()
else
 fuil()
 return b3
end

end


file=POST(xxxxxxx.."/"..xxxxxxx_file.."&app="..xxxxxxx_APPID,"")
file=RC4(eyccd(file),xxxxxxx_RC4_key)
msg=file:match('"msg":"(.-)",')
if msg=="该应用下无外链" then
gg.alert("请先在后台添加文件")
os.exit()
end
b1=file:match('file_url":(.-)}]')
b='{"file_url":'..b1..'}'
b=string.gsub(b,"s:","+!")
b=string.gsub(b,':',']=')
b=string.gsub(b,"{","{[")
b=string.gsub(b,',"',',["')
b=string.gsub(b,"+!","s:")
b='{'..b..'}'
fuil=load("b2="..b)--获取名称
if fuil==nil then
gg.alert("提示:\nkey 错误  请联系作者")--对话框
os.exit()
else
 fuil()
end


a={}--获取脚本
a1={}--获取名称
a2={}

function ub(v)--获取并且运行脚本
v=gg.makeRequest(v).content
fuil=load(v)
if fuil~=nil then
gg.alert("提示:\n脚本 错误  请联系作者")--对话框
os.exit()
else
v=RC4(eyccd(v),xxxxxxx_RC4_key)
load(v)()
end
end


function guggui(code)
function ayu(code)
local code="MKL={" .. table.concat({code:byte(0, -1)}, ",") .. "}"
return code
end

load(ayu(code))()
iuz=""
for i, v in ipairs(MKL) do
if v~=93 then
iuz=iuz..string.char(v) 
end
end
return iuz
end

iu=0
for i, v in ipairs(b2) do
if v.note~=nil then
iu=iu+1
a[iu]=v.file_url--获取链接
a1[iu]=v.note.."\n"..guggui(string.gsub(v.date,"=",":"))----获取名字--获取时间
end
end

uuuuio=""
for i, v in ipairs(a) do
uuuuio=uuuuio.."if kl== "..i.." then" .." ub('"..a[i].."')".." end\n"
end

gg.toast("搜索到"..#a1.."个云脚本")--打印
a="-----[云脚本 搜到"..#a1.."个]-----\n"
a=a.."现在时间:"..os.date("\n%Y".."年".."%m".."月".."%d".."日".." ".."%H".."时".."%M".."分".."%S".."秒\n").."-----------------------\n"
a=a.."公告内容:\n"..JSON(Notice).msg.app_gg--获取公告
a=a.."\n-----------------------"
a1[#a1+1]="退出"
uuuuio=uuuuio.."if kl== "..(#a1).." then " .."os.exit()".." end\n"
kl=gg.choice(a1,{},a)--多选界面功能
load(uuuuio)()
end

while true do
  if gg.isVisible(true) then
    gg.setVisible(false)
    oqvqo()
  end
end

