diff --git a/miku/plugins/boobs.lua b/miku/plugins/boobs.lua new file mode 100644 index 0000000..8a90314 --- /dev/null +++ b/miku/plugins/boobs.lua @@ -0,0 +1,68 @@ +local boobs = {} + +boobs.triggers = { + "^/([Bb][Oo][Oo][Bb][Ss])$", + "^/([Bb][Uu][Tt][Tt][Ss])$" +} + +boobs.command = 'boobs, /butts' + +-- Recursive function +function boobs:getRandomButts(attempt) + attempt = attempt or 0 + attempt = attempt + 1 + + local res,status = http.request("http://api.obutts.ru/noise/1") + + if status ~= 200 then return nil end + local data = json.decode(res)[1] + + -- The OpenBoobs API sometimes returns an empty array + if not data and attempt <= 3 then + print('Keine Butts gefunden!') + return getRandomButts(attempt) + end + + return 'http://media.obutts.ru/' .. data.preview +end + +function boobs:getRandomBoobs(attempt) + attempt = attempt or 0 + attempt = attempt + 1 + + local res,status = http.request("http://api.oboobs.ru/noise/1") + + if status ~= 200 then return nil end + local data = json.decode(res)[1] + + -- The OpenBoobs API sometimes returns an empty array + if not data and attempt < 10 then + print('Keine Boobs gefunden!') + return getRandomBoobs(attempt) + end + + return 'http://media.oboobs.ru/' .. data.preview +end + +function boobs:action(msg, config, matches) + local url + + if matches[1]:match("[Bb][Oo][Oo][Bb][Ss]") then + url = boobs:getRandomBoobs() + end + + if matches[1]:match("[Bb][Uu][Tt][Tt][Ss]") then + url = boobs:getRandomButts() + end + + if url ~= nil then + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file, url) + return + else + utilities.send_reply(self, msg, 'Nichts gefunden :(') + return + end +end + +return boobs diff --git a/miku/plugins/danbooru.lua b/miku/plugins/danbooru.lua new file mode 100644 index 0000000..1cc4b6c --- /dev/null +++ b/miku/plugins/danbooru.lua @@ -0,0 +1,112 @@ +local danbooru = {} + +function danbooru:init(config) + danbooru.triggers = { + "^/dan$", + "^/dan (d)$", + "^/dan (w)$", + "^/dan (m)$", + "^/(dan) (.+)$", + "(danbooru.donmai.us)/posts/([0-9]+)" + } + danbooru.doc = [[* +]]..config.cmd_pat..[[dan*: Zufälliges Bild von Danbooru +*]]..config.cmd_pat..[[dan* __: Zufälliges Bild von Danbooru (populär heute/in der Woche/im Monat) +*]]..config.cmd_pat..[[dan* __: Sucht auf Danbooru mit diesen Tags +]] +end + +danbooru.command = 'dan ' + +local BASE_URL = "http://danbooru.donmai.us" +local URL_NEW = "/posts.json" +local URL_POP = "/explore/posts/popular.json" + +local scale_day = "?scale=day" +local scale_week = "?scale=week" +local scale_month = "?scale=month" + +function danbooru:get_post(url) + local res, code = http.request(url) + if code ~= 200 then return nil end + local posts = json.decode(res) + if not posts[1] then return nil end + + return posts[math.random(#posts)] +end + +function danbooru:get_specific_post(id) + local url = BASE_URL..'/posts/'..id..'.json' + local res, code = http.request(url) + if code ~= 200 then return nil end + local db = json.decode(res) + local link_image = BASE_URL..db.file_url + return link_image +end + +function danbooru:action(msg, config, matches) + if matches[1] == 'danbooru.donmai.us' and matches[2] then + local url = danbooru:get_specific_post(matches[2]) + if not url then utilities.send_reply(self, msg, config.errors.connection) return end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + if string.ends(url, ".gif") or string.ends(url, ".zip") or string.ends(url, ".webm") then + utilities.send_document(self, msg.chat.id, file) + else + utilities.send_photo(self, msg.chat.id, file) + end + return + end + + + if matches[1] == "d" or matches[1] == "w" or matches[1] == "m" then + url = BASE_URL..URL_POP + else + url = BASE_URL..URL_NEW + end + + if matches[1] == "d" then + url = url..scale_day + elseif matches[1] == "w" then + url = url..scale_week + elseif matches[1] == "m" then + url = url..scale_month + elseif matches[1] == "dan" and matches[2] then + local tag = string.gsub(matches[2], " ", '_' ) + local tag = string.gsub(tag, ":", '%%3A' ) + url = url..'?tags='..tag + end + + local post = danbooru:get_post(url) + + if post then + local download_url = BASE_URL..post.large_file_url + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local img = download_to_file(download_url) + if string.ends(download_url, ".gif") or string.ends(download_url, ".zip") or string.ends(download_url, ".webm") then + utilities.send_document(self, msg.chat.id, img) + else + utilities.send_photo(self, msg.chat.id, img) + end + + local txt = '' + if post.tag_string_artist ~= '' then + txt = 'Artist: ' .. post.tag_string_artist .. '\n' + end + if post.tag_string_character ~= '' then + txt = txt .. 'Charakter: ' .. post.tag_string_character .. '\n' + end + if post.file_size ~= '' then + txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. BASE_URL .. post.file_url + end + if txt ~= '' then + utilities.send_reply(self, msg, txt) + end + return + else + utilities.send_reply(self, msg, config.errors.results) + return + end +end + +return danbooru \ No newline at end of file diff --git a/miku/plugins/derpibooru.lua b/miku/plugins/derpibooru.lua new file mode 100644 index 0000000..d639e1d --- /dev/null +++ b/miku/plugins/derpibooru.lua @@ -0,0 +1,43 @@ +local derpibooru = {} + +function derpibooru:init(config) + derpibooru.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('dp', true):t('derpibooru', true).table + derpibooru.doc = [[* +]]..config.cmd_pat..[[dp* __: Sucht auf Derpibooru mit diesen Tags]] +end + +derpibooru.command = 'dp ' + +function derpibooru:get_dp(tag) + local BASE_URL = 'https://derpiboo.ru/' + local url = BASE_URL..'/search.json?q='..tag + + local res, code = https.request(url) + if code ~= 200 then return nil end + local dp = json.decode(res).search + if not dp[1] then return nil end + + local i = math.random(#dp) + local link_image = 'https:'..dp[i].image + local source = 'https://derpiboo.ru/'..dp[i].id + return link_image, source +end + +function derpibooru:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, derpibooru.doc, true) + return + end + local tag = string.gsub(input, " ", '+' ) + local url, source = derpibooru:get_dp(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file, source) +end + +return derpibooru \ No newline at end of file diff --git a/miku/plugins/derpibooru_nsfw.lua b/miku/plugins/derpibooru_nsfw.lua new file mode 100644 index 0000000..e4f597c --- /dev/null +++ b/miku/plugins/derpibooru_nsfw.lua @@ -0,0 +1,49 @@ +local derpibooru_nsfw = {} + +function derpibooru_nsfw:init(config) + if not cred_data.derpibooru_apikey then + print('Fehlender Key: derpibooru_apikey.') + print('derpibooru_nsfw.lua wird nicht aktiviert.') + return + end + derpibooru_nsfw.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('dp_nsfw', true):t('derpibooru_nsfw', true).table + derpibooru_nsfw.doc = [[* +]]..config.cmd_pat..[[dp_nsfw* __: Sucht auf Derpibooru mit diesen Tags (NSFW)]] +end + +derpibooru_nsfw.command = 'dp_nsfw ' + +function derpibooru_nsfw:get_dp(tag) + local BASE_URL = 'https://derpiboo.ru/' + local apikey = cred_data.derpibooru_apikey + local url = BASE_URL..'/search.json?key='..apikey..'&q='..tag + + local res, code = https.request(url) + if code ~= 200 then return nil end + local dp = json.decode(res).search + if not dp[1] then return nil end + + local i = math.random(#dp) + local link_image = 'https:'..dp[i].image + local source = 'https://derpiboo.ru/'..dp[i].id + return link_image, source +end + +function derpibooru_nsfw:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, derpibooru_nsfw.doc, true) + return + end + local tag = string.gsub(input, " ", '+' ) + local url, source = derpibooru_nsfw:get_dp(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file, source) +end + +return derpibooru_nsfw \ No newline at end of file diff --git a/miku/plugins/e621.lua b/miku/plugins/e621.lua new file mode 100644 index 0000000..17e9825 --- /dev/null +++ b/miku/plugins/e621.lua @@ -0,0 +1,40 @@ +local e621 = {} + +function e621:init(config) + e621.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('e621', true).table + e621.doc = [[* +]]..config.cmd_pat..[[e621* __: Sucht auf e621 mit diesen Tags]] +end + +e621.command = 'e621 ' + +function e621:get_e621(tag) + local BASE_URL = 'https://e621.net' + local url = BASE_URL..'/post/index.json?tags='..tag + local res, code = https.request(url) + if code ~= 200 then return nil end + local data = json.decode(res) + if not data[1] then return nil end + + local i = math.random(#data) + local link_image = data[i].file_url + return link_image +end + +function e621:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, e621.doc, true) + return + end + local url = e621:get_e621(input) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file, url) +end + +return e621 \ No newline at end of file diff --git a/miku/plugins/gifeye.lua b/miku/plugins/gifeye.lua new file mode 100644 index 0000000..b602e4e --- /dev/null +++ b/miku/plugins/gifeye.lua @@ -0,0 +1,32 @@ +local gifeye = {} + +function gifeye:init(config) + gifeye.triggers = { + "https?://gifeye.com/(%d+)$", + "^/gifeye (%d+)$", + "^/ge (%d+)$" + } + gifeye.doc = [[* +]]..config.cmd_pat..[[ge* __: Sendet Bild von Gifeye (NSFW)]] +end + +gifeye.command = 'ge ' + +function gifeye:action(msg, config, matches) + local url = 'http://i.gifeye.com/'..matches[1]..'.gif' + utilities.send_typing(self, msg.chat.id, 'upload_document') + local file = download_to_file(url) + if not file then + utilities.send_reply(self, msg, config.errors.results) + return + end + + if string.starts(msg.text_lower, '/ge') or string.starts(msg.text_lower, '/gifeye') then + source = 'http://gifeye.com/'..matches[1] + else + source = nil + end + utilities.send_document(self, msg.chat.id, file, source) +end + +return gifeye \ No newline at end of file diff --git a/miku/plugins/konachan.lua b/miku/plugins/konachan.lua new file mode 100644 index 0000000..ab2540c --- /dev/null +++ b/miku/plugins/konachan.lua @@ -0,0 +1,41 @@ +local konachan = {} + +function konachan:init(config) + konachan.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('kc', true):t('konachan', true).table + konachan.doc = [[* +]]..config.cmd_pat..[[kc* __: Sucht auf Konachan mit diesen Tags]] +end + +konachan.command = 'kc ' + +function konachan:get_kc(tag) + local url = 'http://konachan.net/post.json?tags='..tag..'%20-rating:explicit' + local res, code = http.request(url) + if code ~= 200 then return nil end + local data = json.decode(res) + if not data[1] then return nil end + + local i = math.random(#data) + local link_image = data[i].file_url + return link_image +end + +function konachan:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, konachan.doc, true) + return + end + local tag = string.gsub(input, " ", '+' ) + local url = konachan:get_kc(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file) + utilities.send_reply(self, msg, url) +end + +return konachan \ No newline at end of file diff --git a/miku/plugins/konachan_nsfw.lua b/miku/plugins/konachan_nsfw.lua new file mode 100644 index 0000000..7d750b2 --- /dev/null +++ b/miku/plugins/konachan_nsfw.lua @@ -0,0 +1,41 @@ +local konachan_nsfw = {} + +function konachan_nsfw:init(config) + konachan_nsfw.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('kcn', true):t('konachan_nsfw', true).table + konachan_nsfw.doc = [[* +]]..config.cmd_pat..[[kcn* __: Sucht auf Konachan mit diesen Tags (NSFW)]] +end + +konachan_nsfw.command = 'kcn ' + +function konachan_nsfw:get_kc(tag) + local url = 'http://konachan.net/post.json?tags='..tag + local res, code = http.request(url) + if code ~= 200 then return nil end + local data = json.decode(res) + if not data[1] then return nil end + + local i = math.random(#data) + local link_image = data[i].file_url + return link_image +end + +function konachan_nsfw:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, konachan_nsfw.doc, true) + return + end + local tag = string.gsub(input, " ", '+' ) + local url = konachan_nsfw:get_kc(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file) + utilities.send_reply(self, msg, url) +end + +return konachan_nsfw \ No newline at end of file diff --git a/miku/plugins/moe.lua b/miku/plugins/moe.lua new file mode 100644 index 0000000..f5a8ecf --- /dev/null +++ b/miku/plugins/moe.lua @@ -0,0 +1,41 @@ +local moe = {} + +function moe:init(config) + moe.triggers = { + "^/([Rr][Ii][Kk][Oo])$", + "^/([Yy][Aa][Gg][Yy][Uu][Uu])$" + } + moe.doc = [[* +]]..config.cmd_pat..[[riko*: Postet ein Bild von riko.moe +*]]..config.cmd_pat..[[yagyuu*: Postet ein Bild von yagyuu.moe +]] +end + +moe.command = 'riko, /yagyuu' + +function moe:get_url(site_url) + local res,code = http.request(site_url) + if code ~= 200 then return nil end + local photo_url = res:match("_: Sendet GIF von PornHub (NSFW)]] +end + +pornhub.command = 'ge ' + +function pornhub:action(msg, config, matches) + local url = 'http://img.pornhub.com/gif/'..matches[1]..'.gif' + utilities.send_typing(self, msg.chat.id, 'upload_document') + local file = download_to_file(url) + if not file then + utilities.send_reply(self, msg, config.errors.results) + return + end + + if string.starts(msg.text_lower, '/phg') or string.starts(msg.text_lower, '/porngif') then + source = 'http://www.pornhub.com/gif/'..matches[1] + else + source = nil + end + utilities.send_document(self, msg.chat.id, file, source) +end + +return pornhub \ No newline at end of file diff --git a/miku/plugins/pr0gramm.lua b/miku/plugins/pr0gramm.lua new file mode 100644 index 0000000..7eea997 --- /dev/null +++ b/miku/plugins/pr0gramm.lua @@ -0,0 +1,43 @@ +local pr0gramm = {} + +function pr0gramm:init(config) + pr0gramm.triggers = { + "pr0gramm.com/.*/(%d+)", + "^/[Pp][Rr]0 (%d+)$" + } + pr0gramm.doc = [[* +]]..config.cmd_pat..[[pr0* __: Sendet Bild von pr0gramm]] +end + +pr0gramm.command = 'pr0 ' + +function pr0gramm:get_post(id) + local url = 'http://pr0gramm.com/api/items/get.json?id='..id + local res, code = http.request(url) + if code ~= 200 then return nil end + local data = json.decode(res).items[1] + if not data then return nil end + + local img = data.image + + return 'http://img.pr0gramm.com/'..img +end + +function pr0gramm:action(msg, config, matches) + local id = matches[1] + local url = pr0gramm:get_post(id) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + if string.match(url, ".gif") or string.match(url, ".zip") or string.match(url, ".webm") or string.match(url, ".mp4") then + utilities.send_document(self, msg.chat.id, file) + else + utilities.send_photo(self, msg.chat.id, file) + end +end + +return pr0gramm \ No newline at end of file diff --git a/miku/plugins/random_pic.lua b/miku/plugins/random_pic.lua new file mode 100644 index 0000000..87f37f7 --- /dev/null +++ b/miku/plugins/random_pic.lua @@ -0,0 +1,63 @@ +local rpic = {} + +function rpic:init(config) + rpic.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('rpic', true).table + rpic.doc = [[* +]]..config.cmd_pat..[[rpic* __ +*Themen:* +- anime +- mlp +- doge +- faktillion +- faktastisch +- gamefakt +- faktglaublich]] +end + +rpic.command = 'rpic ' + +function rpic:get_random_image(dir) + files = scandir(dir) + if not files[1] then return ': Keine Dateien vorhanden!' end + file = files[math.random(#files)] + return file +end + +function rpic:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, rpic.doc, true) + return + end + + local pics = { + ["test"] = "../Festplatten/Dragoran/Mikubot/sfw/test/", + ["anime"] = "../Festplatten/Dragoran/Mikubot/sfw/anime/", + ["mlp"] = "../Festplatten/Dragoran/Mikubot/sfw/mlp/", + ["doge"] = "../Festplatten/Dragoran/Mikubot/sfw/doge/", + ["faktillon"] = "../Festplatten/Dragoran/Mikubot/sfw/faktillon/", + ["faktastisch"] = "../Festplatten/Dragoran/Mikubot/sfw/faktastisch/", + ["gamefakt"] = "../Festplatten/Dragoran/Mikubot/sfw/gamefakt/", + ["faktglaublich"] = "../Festplatten/Dragoran/Mikubot/sfw/faktglaublich/" + } + + if pics[input] then + local img = pics[input]..rpic:get_random_image(pics[input]) + print("Sende... "..img) + if string.ends(img, ".gif") or string.ends(img, ".mp4") then + utilities.send_document(self, msg.chat.id, img) + return + elseif string.ends(img, ".jpg") or string.ends(img, ".jpeg") or string.ends(img, ".png") then + utilities.send_photo(self, msg.chat.id, img) + return + else + utilities.send_reply(self, msg, 'Fehler: '..img) + return + end + else + utilities.send_reply(self, msg, '*Dieses Thema gibt es nicht!*'..rpic.doc, true) + return + end +end + +return rpic \ No newline at end of file diff --git a/miku/plugins/random_pic_nsfw.lua b/miku/plugins/random_pic_nsfw.lua new file mode 100644 index 0000000..737bca1 --- /dev/null +++ b/miku/plugins/random_pic_nsfw.lua @@ -0,0 +1,54 @@ +local rpic_nsfw = {} + +function rpic_nsfw:init(config) + rpic_nsfw.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('nsfw', true).table + rpic_nsfw.doc = [[* +]]..config.cmd_pat..[[nsfw* __ +*Themen:* +- gif +- rl +- shimakaze]] +end + +rpic_nsfw.command = 'nsfw ' + +function rpic_nsfw:get_random_image(dir) + files = scandir(dir) + if not files[1] then return ': Keine Dateien vorhanden!' end + file = files[math.random(#files)] + return file +end + +function rpic_nsfw:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + input = 'general' + end + + local pics = { + ["general"] = "../Festplatten/Dragoran/Mikubot/nsfw/", + ["gif"] = "../Festplatten/Dragoran/Mikubot/nsfw/gifs/", + ["rl"] = "../Festplatten/Dragoran/Mikubot/nsfw/rl/", + ["shimakaze"] = "../Festplatten/Dragoran/Mikubot/nsfw/Shimakaze/" + } + + if pics[input] then + local img = pics[input]..rpic_nsfw:get_random_image(pics[input]) + print("Sende... "..img) + if string.ends(img, ".gif") or string.ends(img, ".mp4") then + utilities.send_document(self, msg.chat.id, img) + return + elseif string.ends(img, ".jpg") or string.ends(img, ".jpeg") or string.ends(img, ".png") then + utilities.send_photo(self, msg.chat.id, img) + return + else + utilities.send_reply(self, msg, 'Fehler: '..img) + return + end + else + utilities.send_reply(self, msg, '*Dieses Thema gibt es nicht!*'..rpic_nsfw.doc, true) + return + end +end + +return rpic_nsfw \ No newline at end of file diff --git a/miku/plugins/rule34.lua b/miku/plugins/rule34.lua new file mode 100644 index 0000000..6a10f72 --- /dev/null +++ b/miku/plugins/rule34.lua @@ -0,0 +1,81 @@ +local rule34 = {} + +function rule34:init(config) + rule34.triggers = { + "^/r34 (.+)$", + "^/rule34 (.+)$", + "https?://(rule34.xxx)/index.php%?page=post&s=view&id=(%d+)" + } + rule34.doc = [[* +]]..config.cmd_pat..[[r34* __: Sucht auf Rule34 mit diesen Tags (NSFW)]] +end + +rule34.command = 'r34 ' + +function rule34:get_r34_info(tag) + local limit = 100 -- number of posts to return (higher = more choices for random, but longer load times, hard limit of 100 posts) + local BASE_URL = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Frule34.xxx%2Findex.php%3Fpage%3Ddapi%26s%3Dpost%26q%3Dindex%26limit%3D'..limit..'%26tags%3D' + local END_URL = '%27&format=json' + local url = BASE_URL..tag..END_URL + local res, code = https.request(url) + if code ~= 200 then return nil end + local r34 = json.decode(res).query.results.posts.post + if not r34[1] then return nil end + + + local i = math.random(#r34) + local url = r34[i].file_url + local source_url = 'http://rule34.xxx/index.php?page=post&s=view&id='..r34[i].id + return url, source_url +end + +function rule34:get_r34_post(id) + local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Frule34.xxx%2Findex.php%3Fpage%3Ddapi%26s%3Dpost%26q%3Dindex%26id%3D'..id..'%27&format=json' + local res ,code = https.request(url) + + if code ~= 200 then return nil end + local r34 = json.decode(res).query.results.posts.post + if not r34 then return nil end + + local img_url = r34.file_url + return img_url +end + +function rule34:action(msg, config, matches) + if matches[1] == 'rule34.xxx' and matches[2] then + local id = matches[2] + local img_url = rule34:get_r34_post(id) + if not img_url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(img_url) + if string.ends(img_url, ".gif") then + utilities.send_document(self, msg.chat.id, file) + else + utilities.send_photo(self, msg.chat.id, file) + end + + else + + local tag = string.gsub(matches[1], " ", '_') + local tag = string.gsub(tag, ":", '%%3A') + local tag = string.gsub(tag, "+", '%%2B') + local url, id = rule34:get_r34_info(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + if string.ends(url, ".gif") then + utilities.send_document(self, msg.chat.id, file, id) + else + utilities.send_photo(self, msg.chat.id, file, id) + end + + end +end + +return rule34 \ No newline at end of file diff --git a/miku/plugins/sankakucomplex.lua b/miku/plugins/sankakucomplex.lua new file mode 100644 index 0000000..0a47cb6 --- /dev/null +++ b/miku/plugins/sankakucomplex.lua @@ -0,0 +1,52 @@ +local sankakucomplex = {} + +function sankakucomplex:init(config) + sankakucomplex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sc', true):t('sankaku', true).table + sankakucomplex.doc = [[* +]]..config.cmd_pat..[[sc* __: Sucht auf Sankaku mit diesen Tags]] +end + +sankakucomplex.command = 'sc ' + +function sankakucomplex:get_post(tag) + local user = cred_data.sankaku_username + local password = cred_data.sankaku_pw --Your SHA1 hashed password. (echo "choujin-steiner--YOUR-PASSWORD--" | sha1sum) + local BASE_URL = 'https://chan.sankakucomplex.com' + local url = BASE_URL..'/post/index.json?login='..user..'&password_hash='..password..'&tags='..tag + local b,c = https.request(url) + if c ~= 200 then return nil end + local complex = json.decode(b) + if not complex[1] then return nil end + + local i = math.random(#complex) + local link_image = 'https:'..complex[i].file_url + return link_image +end + +function sankakucomplex:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, sankakucomplex.doc, true) + return + end + + local tag = string.gsub(input, " ", '_' ) + local tag = string.gsub(tag, ":", '%%3A' ) + + local url = sankakucomplex:get_post(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + if string.match(url, ".gif") or string.match(url, ".zip") or string.match(url, ".webm") or string.match(url, ".mp4") then + utilities.send_document(self, msg.chat.id, file) + else + utilities.send_photo(self, msg.chat.id, file) + end + utilities.send_reply(self, msg, url) +end + +return sankakucomplex \ No newline at end of file diff --git a/miku/plugins/yandere.lua b/miku/plugins/yandere.lua new file mode 100644 index 0000000..3c1844d --- /dev/null +++ b/miku/plugins/yandere.lua @@ -0,0 +1,44 @@ +local yandere = {} + +function yandere:init(config) + yandere.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('yan', true):t('yandere', true).table + yandere.doc = [[* +]]..config.cmd_pat..[[yan* __: Sucht auf Yandere mit diesen Tags]] +end + +yandere.command = 'yan ' + +function yandere:get_post(tag) + local BASE_URL = 'https://yande.re' + local url = BASE_URL..'/post.json?tags='..tag + local b,c = https.request(url) + print(url) + if c ~= 200 then return nil end + local yan = json.decode(b) + if not yan[1] then return nil end + + local i = math.random(#yan) + local link_image = yan[i].file_url + return link_image +end + +function yandere:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(self, msg, yandere.doc, true) + return + end + + local tag = string.gsub(input, " ", '_' ) + local url = yandere:get_post(tag) + if not url then + utilities.send_reply(self, msg, config.errors.results) + return + end + utilities.send_typing(self, msg.chat.id, 'upload_photo') + local file = download_to_file(url) + utilities.send_photo(self, msg.chat.id, file) + utilities.send_reply(self, msg, url) +end + +return yandere \ No newline at end of file diff --git a/miku/plugins/z0r.lua b/miku/plugins/z0r.lua new file mode 100644 index 0000000..a80f833 --- /dev/null +++ b/miku/plugins/z0r.lua @@ -0,0 +1,26 @@ +local z0r = {} + +function z0r:init(config) + z0r.triggers = { + "https?://z0r.de/(%d+)$", + "^/[Zz]0[Rr] (%d+)$" + } + z0r.doc = [[* +]]..config.cmd_pat..[[z0r* __: Sendet Loop von z0r]] +end + +z0r.command = 'z0r ' + +function z0r:action(msg, config, matches) + local id = matches[1] + utilities.send_typing(self, msg.chat.id, 'upload_video') + local url = 'http://z0r.de/L/z0r-de_'..matches[1]..'.swf' + local file = download_to_file(url) + if not file then + utilities.send_reply(self, msg, config.errors.connection) + return + end + utilities.send_document(self, msg.chat.id, file) +end + +return z0r \ No newline at end of file