From 13f8729504b3c28d0b0c32352eb6b607f270ee49 Mon Sep 17 00:00:00 2001 From: chenxuuu Date: Fri, 24 May 2019 23:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=90=9C=E5=9B=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appdata/lua/require/app/hitokoto.lua | 39 +++++++++++++++++++++++++ appdata/lua/require/app/imageSearch.lua | 33 --------------------- 2 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 appdata/lua/require/app/hitokoto.lua delete mode 100644 appdata/lua/require/app/imageSearch.lua diff --git a/appdata/lua/require/app/hitokoto.lua b/appdata/lua/require/app/hitokoto.lua new file mode 100644 index 0000000..522eb55 --- /dev/null +++ b/appdata/lua/require/app/hitokoto.lua @@ -0,0 +1,39 @@ +--一言 +return function () + local say = apiHttpGet("http://v1.hitokoto.cn") + + local types = { + a = "Anime - 动画", + b = "Comic – 漫画", + c = "Game – 游戏", + d = "Novel – 小说", + e = "Myself – 原创", + f = "Internet – 来自网络", + g = "Other – 其他", + } + + function getText(s) + if not s then return end + + local data = JSON:decode(s) + if not s then return end + + local hitokoto,saytype,from + if not pcall(function () + hitokoto,saytype,from = data.hitokoto, data.type, data.from + end) then + return + end + + return hitokoto.."\r\n--"..from.."\r\n"..types[saytype] + end + + return getText(say) or at(fromqq).."\r\n加载失败啦" + +end + + + + + + diff --git a/appdata/lua/require/app/imageSearch.lua b/appdata/lua/require/app/imageSearch.lua deleted file mode 100644 index 90e96e3..0000000 --- a/appdata/lua/require/app/imageSearch.lua +++ /dev/null @@ -1,33 +0,0 @@ ---搜图 ---api key请用自己的 -local key = apiXmlGet("settings","saucenao") - -local function getPixivId(pic) - local html = apiHttpGet("https://saucenao.com/search.php?"..(key and "api_key="..key.."&" or "").. - "db=999&output_type=2&numres=16&url="..pic:urlEncode(),"",30000) - local t,r,_ = jsonDecode(html) - if not r or not t then return "查找失败" end - if not t.results or #t.results==0 then return "未找到结果" end - local result = "" - for i=1,#t.results do - if t.results[i].header.index_id == 5 and tonumber(t.results[i].header.similarity) > 70 then - return (t.results[i].header.thumbnail and image(t.results[i].header.thumbnail) or "").."\r\n".. - (t.results[i].data.title and t.results[i].data.title or "").."\r\n".. - (t.results[i].data.pixiv_id and "p站id:"..t.results[i].data.pixiv_id or "").."\r\n".. - (t.results[i].data.member_name and "画师:"..t.results[i].data.member_name or "").."\r\n".. - (t.results[i].data.ext_urls[1] and t.results[i].data.ext_urls[1] or "") - elseif tonumber(t.results[i].header.similarity) > 70 then - return (t.results[i].header.thumbnail and image(t.results[i].header.thumbnail) or "").."\r\n".. - (t.results[i].data.ext_urls[1] and t.results[i].data.ext_urls[1] or "") - end - end - return "未找到结果" -end - -return function (message) - local pic = apiGetImageUrl(message) - if pic ~= "" then - return getPixivId(pic) - end -end -