diff --git a/plugins/dmm.lua b/plugins/dmm.lua new file mode 100644 index 0000000..81862f2 --- /dev/null +++ b/plugins/dmm.lua @@ -0,0 +1,60 @@ +do + +function get_videos(html) + local videos = {} + for p in html:gmatch("
.-
(.*)"):gsub("<.->", ""):match("^%s*(.-)%s*$")
+ })
+ end
+ return videos
+end
+
+function get_dmm(rawid)
+ local label, num = string.match(rawid, "(%a+).-(%d+)")
+ local id = string.format("%s%05d", label:lower(), num)
+ local res, code = http.request("http://www.dmm.co.jp/search/=/searchstr="..id)
+ if code ~= 200 then return "HTTP ERROR" end
+ return get_videos(res)[1]
+end
+
+function get_dmm_random()
+ local res, code = http.request("http://www.dmm.co.jp/digital/videoa/-/list/=/sort=ranking/")
+ if code ~= 200 then return "HTTP ERROR" end
+ local videos = get_videos(res)
+ return videos[math.random(1, #videos)]
+end
+
+function send_title(cb_extra, success, result)
+ if success then
+ local message = cb_extra[2] .. "\n" .. cb_extra[3] .. "\n" ..cb_extra[4]
+ send_msg(cb_extra[1], message, ok_cb, false)
+ end
+end
+
+function run(msg, matches)
+ local receiver = get_receiver(msg)
+ if matches[1] == "/dmm" then
+ video = get_dmm_random()
+ else
+ video = get_dmm(matches[1])
+ end
+ file_path = download_to_file(video.img)
+ send_photo(receiver, file_path, send_title, {receiver, video.title, video.name, video.link})
+ return false
+end
+
+return {
+ description = "Send dmm video info",
+ usage = {"/dmm (id): Send a dmm video cover and title. If not id, send a random one"},
+ patterns = {
+ "^/dmm$",
+ "^/dmm (.+)"
+ },
+ run = run
+}
+
+end
\ No newline at end of file
diff --git a/plugins/ehentai.lua b/plugins/ehentai.lua
new file mode 100644
index 0000000..f75eb4e
--- /dev/null
+++ b/plugins/ehentai.lua
@@ -0,0 +1,72 @@
+do
+
+function get_high_rating()
+ local res, code = http.request("http://g.e-hentai.org/?f_doujinshi=1&f_manga=1&f_artistcg=1&f_gamecg=1&f_western=0&f_non-h=1&f_imageset=1&f_cosplay=1&f_asianporn=1&f_misc=1&f_search=&f_apply=Apply+Filter&advsearch=1&f_sname=on&f_stags=on&f_sr=on&f_srdd=4")
+ if code ~= 200 then return "HTTP ERROR" end
+ local gidlist = {}
+ for gid, gtok in res:gmatch("http://g.e%-hentai.org/g/([^/]+)/([^/]+)/") do
+ table.insert(gidlist, {gid, gtok})
+ end
+ gidlist = {gidlist[math.random(1, #gidlist)]}
+ local reqbody = json:encode{method="gdata", gidlist=gidlist}
+ local resbody = {}
+ local result, respcode, respheaders, respstatus = http.request {
+ url="http://g.e-hentai.org/api.php",
+ method="POST",
+ headers={
+ ["Content-Type"]="application/json",
+ ["Content-Length"]=tostring(#reqbody)
+ },
+ source=ltn12.source.string(reqbody),
+ sink=ltn12.sink.table(resbody),
+ }
+ local data = json:decode(resbody[1]).gmetadata[1]
+ return data.thumb, data.title .. '\n' .. data.title_jpn .. '\n' .. 'rating: ' .. data.rating .. '\n' .. "http://g.e-hentai.org/g/" .. data.gid .. '/' .. data.token
+end
+
+function get_popular()
+ local res, code = http.request("http://g.e-hentai.org/")
+ if code ~= 200 then return "HTTP ERROR" end
+ local mangas = {}
+ for p in res:gmatch("class=\"id1\"(.-)class=\"id44\"") do
+ table.insert(mangas, {
+ link = p:match("href=\"(.-)\""),
+ img = p:match("img src=\"(.-)\""),
+ title = p:match("title=\"(.-)\"")
+ })
+ end
+ local manga = mangas[math.random(1, #mangas)]
+ return manga.img, manga.title .. '\n' .. manga.link
+end
+
+function run(msg, matches)
+ local url = nil
+ local txt = nil
+ if matches[1] == "/eh" then
+ url, txt = get_popular()
+ elseif matches[1] == "pop" then
+ url, txt = get_popular()
+ elseif matches[1] == "top" then
+ url, txt = get_high_rating()
+ end
+ local receiver = get_receiver(msg)
+ send_photo_from_url(receiver, url)
+ return txt
+end
+
+return {
+ description = "Send an e-hentai manga info.",
+ usage = {
+ "/eh: Send an popular right now e-hentai manga info which is popular right now.",
+ "/eh pop: Send an popular right now e-hentai manga info which is popular right now.",
+ "/eh top: Send a > 4-star e-hentai manga info."
+ },
+ patterns = {
+ "^/eh$",
+ "^/eh (pop)$",
+ "^/eh (top)$",
+ },
+ run = run
+}
+
+end
\ No newline at end of file
diff --git a/plugins/minecraft.lua b/plugins/minecraft.lua
new file mode 100644
index 0000000..96e3e13
--- /dev/null
+++ b/plugins/minecraft.lua
@@ -0,0 +1,117 @@
+-- -- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss