function onLoad(bot)
print("载入AIO bot"..bot.getId().."成功")
_aks = "737780365f656c04b4c405" --请在""中输入apikey
_apikey = "32d97878cf0e765e1e9d382a3b30b08e3f7b460d"
master = {1240188105} --请改为你的QQ,多管理员用,隔开
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/help") then
group:sendMsg("/p站搜图 - 以文字在P站搜索图片,但无法过滤R18 \n/一言 - 获取一言\n/二次元 - 获取二次元图片\n/menhera - 获取menhera图片\n/涩图 - 获取一张随机的涩图\n/st+关键字 - 搜索一张涩图\n/网抑云 - 获取网抑云语录\n/壁纸 - 获取一张壁纸\n/以图搜图 - 以一张图片获取一张图片")
end
end)
--p站搜图
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/p站搜图") then
group:sendMsg("正在搜索")
api_value = msg.gsub("/p站搜图","")
api_value = api_value.gsub(" ","")
function Table_Rand(t)
if t == nil then
return
end
local tRet = {}
local Total = #t
while Total > 0 do
local i = math.random(1,Total)
table.insert(tRet,t[i])
t[i] = t[Total]
Total = Total -1
end
return tRet
end
local urls = {}
local count = 0
while true do
count = count+1
api_json = ("https.//api.imjad.cn/pixiv/v2/?type=search&word=" .. api_value .. "&page=" ..count)
html = net.get(api_json)
if html.find('next_url".null') then
break
end
for i in html.gmatch('"original_image_url"."(.-)"') do
url1 = i.gsub("\\","")
url = url1.gsub("i.pximg.net","i.pixiv.cat")
table.insert(urls,url)
end
if count>10 then
break
end
end
group:sendMsg("解析完成")
local list = Table_Rand(urls)
local x = 0
for j,k in pairs(list) do
if x>5 then
break
end
x = x+1
group:sendMsg(FlashImage(Image(k,group)))
end
end
end)
--一言
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/一言") then
group:sendMsg( Msg().setQuote(msg)+"你要的一言来了.\n"+net.get("https.//api.ixiaowai.cn/ylapi/index.php"))
end
end)
--回复
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("中二") then
group:sendMsg(Msg().setQuote(msg)+"吾乃赤电魔教之教主,吾即是真理。\n来吧!吾等赤众们啊!\n今晚是嗜血之夜,血红之月乃我们前进的指标。\n吾封印之右手,觉醒吧!破坏吧!\n吞噬吾之敌人!欧 洲 之 魔 手!!!(学miru讲话")
end
end)
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("夸我") then
group:sendMsg(Msg().setQuote(msg)+net.get("https.//chp.shadiao.app/api.php"))
end
end)
bot:subscribe("GroupMessageEvent",function(event)
if event.message == "骂我" then
event.group:sendMessage(Quote(msg) + At(sender) + Http.get("https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn"))
elseif event.message:find("骂他") then
local at
for k, v in pairs(event.message:toTable()) do
if v:find("mirai:at") then
at = v
break
end
end
event.group:sendMessage(at .. Http.get("https://nmsl.shadiao.app/api.php?lang=zh_cn"))
end
end)
--二次元
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/二次元") then
local erciyuan = ("https.//api.ixiaowai.cn/api/api.php")
group:sendMsg(Msg().setQuote(msg)+Msg().appendImage(erciyuan, group) )
end
end)
--menhare
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/menhera") then
local menhera = ("https.//api.ixiaowai.cn/mcapi/mcapi.php")
group:sendMsg(Msg().appendImage(menhera, group) )
end
end)
--涩图
bot:subscribeGroupMsg("GroupMessageEvent",function(event)
if event.message:find("/涩图") then
group:sendMsg(FlashImage(Image(Net.get("https.//api.lolicon.app/setu/").match('"url"."(.-)"').gsub("\\", ""), group)))
end
end)
--搜索涩图
_r18 = 0
bot:subscribeGroupMsg("GroupMessageEvent",function(event)
if event.message:find("/开启r18") then
function isInArray(t, val)
for _, v in ipairs(t) do
if v == val then
return true
end
end
return false
end
local TF = isInArray(master,sender.id)
if TF == true then
_r18 = 1
group:sendMsg("r18开启成功")
else
group:sendMsg("请联系bot主人授权")
end
end
if event.message:find("/关闭r18") then
_r18 = 0
group:sendMsg("r18已关闭")
end
if event.message:find("/st") then
group:sendMsg(FlashImage(Image("/096708CE-21F8-3AAD-B8E5-2223D679DAE4",group)))
api_value = msg.gsub("/st","")
if api_value.find(" ",-3)==nil then
api_value = api_value .. " 1"
end
api_num = api_value.match("%d",-2)
api_value = api_value.sub(1,-3)
if api_value == nil then
api_value = ''
end
if api_num == nil then
api_num = 1
end
api_json = ("https.//api.lolicon.app/setu/?apikey=" .. _aks .. "&r18=" .. _r18 .. "&num=" .. api_num .."&keyword=" ..api_value)
html = net.get(api_json)
if html.find("没有符合条件的色图") then
group:sendMsg("没有符合条件的色图")
end
--local m = Msg()
for i in html.gmatch('"url"."(.-)"') do
url = i.gsub("\\","")
--m = m+Image(url,group)
group:sendMsg(Image(url,group)) --一次发一张
end
--group.sendgroup:sendMsg(m) --一次发多张
end
end)
--网抑云
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/网抑云") then
api_json = net.get("http.//api.heerdev.top.4995/nemusic/random")
api_msg = api_json.match([["text"."(.-)"}]])
group:sendMsg(Quote(msg)+api_msg)
end
end)
--壁纸
bot:subscribeGroupMsg(
"GroupMessageEvent",function(event)
if event.message:find("/壁纸") then
group:sendMsg(Image(Net.get("https.//api.ixiaowai.cn/gqapi/gqapi.php"), group) )
end
end)
end
local bot = Bot(x,"x",{
protocol = "ANDROID_PHONE", --使用手表协议登录
fileBasedDeviceInfo = "config/device.json", --指定设备信息路径
noNetworkLog = true --不显示网络日志
})
bot:login()
local group = bot:getGroup(306713737)
onLoad(bot)
登陆好了之后就崩溃
Exception in thread "main" org.luaj.vm2.LuaError: @aio.lua:2 attempt to call nil
at org.luaj.vm2.LuaValue.checkmetatag(LuaValue.java:3365)
at org.luaj.vm2.LuaValue.callmt(LuaValue.java:1997)
at org.luaj.vm2.LuaValue.call(LuaValue.java:1512)
at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:359)
at org.luaj.vm2.LuaClosure.call(LuaClosure.java:142)
at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:357)
at org.luaj.vm2.LuaClosure.call(LuaClosure.java:133)
at com.ooooonly.luakt.LuaCodeRunnerKt.runLuaFile(LuaCodeRunner.kt:14)
at com.ooooonly.luaMirai.MainKt.execFile(main.kt:21)
at com.ooooonly.luaMirai.MainKt.main(main.kt:14)
at com.ooooonly.luaMirai.MainKt$$$main.invoke(Unknown Source)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:199)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:114)
at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
at com.ooooonly.luaMirai.MainKt.main(main.kt)
登陆好了之后就崩溃
如果不加
onLoad(bot)
机器人只登陆,不会做任何动作