From 8e0b6e03395d588a00bed8984b8eb836d8991b52 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Wed, 10 May 2017 13:35:21 +0200 Subject: [PATCH] Updates & Fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit banhammer.lua: Entferne prints pihole.lua: Anpassung an Pi-hole 3.0 playstation_store.lua: Fix für falschen Namen plex.lua: Anpassungen (Achtung, dreckig) special.lua: "Kuma Shock" Neu! get_img.lua --- miku/plugins/banhammer.lua | 10 +++++----- miku/plugins/get_img.lua | 26 +++++++++++++++++++++++++ miku/plugins/pihole.lua | 31 ++---------------------------- miku/plugins/playstation_store.lua | 6 +++++- miku/plugins/plex.lua | 15 ++++++++++++--- miku/plugins/special.lua | 4 ++++ 6 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 miku/plugins/get_img.lua diff --git a/miku/plugins/banhammer.lua b/miku/plugins/banhammer.lua index 2939c01..592c28d 100644 --- a/miku/plugins/banhammer.lua +++ b/miku/plugins/banhammer.lua @@ -141,19 +141,19 @@ function banhammer:pre_process(msg, config) -- Allow all sudo users even if whitelist is allowed if whitelist and not issudo then - print('Whitelist enabled and not sudo') + --print('Whitelist enabled and not sudo') -- Check if user or chat is whitelisted local allowed = banhammer:is_user_whitelisted(user_id) local has_been_warned = redis:hget('user:'..user_id, 'has_been_warned') if not allowed then - print('User '..user_id..' not whitelisted') + --print('User '..user_id..' not whitelisted') if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then allowed = banhammer:is_chat_whitelisted(chat_id) if not allowed then - print ('Chat '..chat_id..' not whitelisted') + --print ('Chat '..chat_id..' not whitelisted') else - print ('Chat '..chat_id..' whitelisted :)') + --print ('Chat '..chat_id..' whitelisted :)') end else if not has_been_warned then @@ -167,7 +167,7 @@ function banhammer:pre_process(msg, config) end end else - print('User '..user_id..' allowed :)') + --print('User '..user_id..' allowed :)') end if not allowed then diff --git a/miku/plugins/get_img.lua b/miku/plugins/get_img.lua new file mode 100644 index 0000000..de0f5ad --- /dev/null +++ b/miku/plugins/get_img.lua @@ -0,0 +1,26 @@ +local get_img = {} + +function get_img:init(config) + get_img.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('getimg', true).table + get_img.doc = '\n*/getimg* __' +end + +get_img.command = 'getimg ' + +function get_img:action(msg, config) + local input = utilities.input_from_msg(msg) + if not input then + utilities.send_reply(msg, get_img.doc, true) + return + end + + utilities.send_typing(msg.chat.id, 'upload_photo') + local img_url = download_to_file(input) + if not img_url then + utilities.send_reply(msg, config.errors.connection) + return + end + utilities.send_photo(msg.chat.id, input, nil, msg.message_id) +end + +return get_img diff --git a/miku/plugins/pihole.lua b/miku/plugins/pihole.lua index e807eac..ee3db54 100644 --- a/miku/plugins/pihole.lua +++ b/miku/plugins/pihole.lua @@ -1,33 +1,7 @@ local pihole = {} function pihole:init(config) - pihole.triggers = {'/[Pp][Ii][Hh][Oo][Ll][ee]'} -end - -function pihole:transeng(ger) - --Days - local ger = string.gsub(ger, "Monday", "Montag") - local ger = string.gsub(ger, "Tuesday", "Dienstag") - local ger = string.gsub(ger, "Wednesday", "Mittwoch") - local ger = string.gsub(ger, "Thursday", "Donnerstag") - local ger = string.gsub(ger, "Friday", "Freitag") - local ger = string.gsub(ger, "Saturday", "Samstag") - local ger = string.gsub(ger, "Sunday", "Sonntag") - - --Months - local ger = string.gsub(ger, "January", "Januar") - local ger = string.gsub(ger, "February", "Februar") - local ger = string.gsub(ger, "March", "März") - local ger = string.gsub(ger, "April", "April") - local ger = string.gsub(ger, "May", "Mai") - local ger = string.gsub(ger, "June", "Juni") - local ger = string.gsub(ger, "July", "Juli") - local ger = string.gsub(ger, "August", "August") - local ger = string.gsub(ger, "September", "September") - local ger = string.gsub(ger, "October", "Oktober") - local ger = string.gsub(ger, "November", "November") - local ger = string.gsub(ger, "December", "Dezember") - return ger + pihole.triggers = {'^/[Pp][Ii][Hh][Oo][Ll][ee]'} end function pihole:get_pihole() @@ -36,12 +10,11 @@ function pihole:get_pihole() if c ~= 200 then return nil end local data = json.decode(b) - local time = os.date("%A den %d. %B %Y") local domains_being_blocked = data.domains_being_blocked local dns_queries_today = data.dns_queries_today local ads_blocked_today = data.ads_blocked_today local ads_percentage_today = data.ads_percentage_today - local text = 'Pi-Hole Statistik vom '..pihole:transeng(time)..'\nGeblockte Domains: '..domains_being_blocked..'\nHeutige DNS-Abfragen: '..dns_queries_today..'\nGeblockte DNS-Abfragen: '..ads_blocked_today..' ('..ads_percentage_today..'%)' + local text = 'Pi-Hole Statistik der letzten 24h\nGeblockte Domains: '..domains_being_blocked..'\nDNS-Abfragen: '..dns_queries_today..'\nGeblockte DNS-Abfragen: '..ads_blocked_today..' ('..ads_percentage_today..'%)' return text end diff --git a/miku/plugins/playstation_store.lua b/miku/plugins/playstation_store.lua index fd2e7e7..555d427 100644 --- a/miku/plugins/playstation_store.lua +++ b/miku/plugins/playstation_store.lua @@ -18,7 +18,7 @@ function playstation_store:get_info(country_code, game_id) local data = json.decode(res) if not data then return nil end - local title = data.title_name + local title = data.name if data.provider_name then publish = ' von '..data.provider_name else @@ -34,6 +34,7 @@ function playstation_store:get_info(country_code, game_id) else types = '' end + if data.skus then if data.skus[1].rewards[1] then --[[ @@ -48,6 +49,9 @@ function playstation_store:get_info(country_code, game_id) else price = data.default_sku.display_price--..psplus end + else + price = 'N/A' + end local fsk = data.age_limit local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...' local release = makeOurDate(data.release_date) diff --git a/miku/plugins/plex.lua b/miku/plugins/plex.lua index 6116579..ac2a241 100644 --- a/miku/plugins/plex.lua +++ b/miku/plugins/plex.lua @@ -24,9 +24,10 @@ end local DESC_LENTH = 400 local plex_token = cred_data.plex_token +local plex_addr = cred_data.plex_addr function plex:get_plex(query) - local baseurl = 'http://hakase.local:32400' --replace it with yours + local baseurl = 'http://'..plex_addr..':32400' local response_body = {} local request_constructor = { url = baseurl..'/search?query='..query..'&X-Plex-Token='..plex_token, @@ -147,7 +148,9 @@ function plex:get_plex(query) else pic = nil end - + + local musicDate = date2:gsub('01.01.', '') --well ._. + if data.librarySectionTitle == 'Animes' then text = title..from..studio..date1..episodes..fsk..duration..rating..desc elseif data.librarySectionTitle == 'Cartoons' then @@ -156,8 +159,14 @@ function plex:get_plex(query) text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc elseif data.librarySectionTitle == 'Filme' then text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc + elseif data.librarySectionTitle == 'Gronkh Streams' then + text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc elseif data.librarySectionTitle == 'Musik' then - text = title..artist..date2..desc + text = title..artist..musicDate..desc + elseif data.librarySectionTitle == 'Musik (Unsortiert!)' then + text = title..artist..musicDate..desc + elseif data.librarySectionTitle == 'Musikvideos' then + text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc elseif data.librarySectionTitle == 'Serien' then text = title..from..studio..date1..episodes..fsk..duration..rating..desc elseif data.librarySectionTitle == 'YouTube Serien' then diff --git a/miku/plugins/special.lua b/miku/plugins/special.lua index 7b4ac5f..4a42c0c 100644 --- a/miku/plugins/special.lua +++ b/miku/plugins/special.lua @@ -23,6 +23,7 @@ special.triggers = { "^[Yy][Oo][Ss][Hh][Ii] [Dd][Aa][Nn][Cc][Ee] [Gg][Ll][Ii][Tt][Cc][Hh]", "^[Yy][Oo][Ss][Hh][Ii] [Dd][Aa][Nn][Cc][Ee]", "^[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]", + "^[Kk][Uu][Mm][Aa] [Ss][Cc]?[Hh][Oo][Cc][Kk]", "^[Ss][Uu][Gg][Oo][Ii] [Dd][Ee][Ss][Uu] [Nn][Ee]", "^[Nn][Aa][Nn][Oo] [Hh][Aa][Kk][Aa][Ss][Ee]$", "^/[Tt][Hh][Yy][Mm][Ee]$", @@ -109,6 +110,9 @@ function special:action(msg, config, matches) elseif msg_text:match("[Nn][Oo][Pp][Ee].[Aa][Vv][Ii]") then utilities.send_video(msg.chat.id, 'http://code.ponywave.de/workspace/test/fuck/nope.mp4', nil, msg.message_id) return + elseif msg_text:match("[Kk][Uu][Mm][Aa] [Ss][Cc]?[Hh][Oo][Cc][Kk]") then + utilities.send_video(msg.chat.id, 'http://code.ponywave.de/workspace/test/fuck/KUMA_SHOCK.mp4', 'KUMA SHOCK!', msg.message_id) + return elseif msg_text:match("[Ss][Uu][Gg][Oo][Ii] [Dd][Ee][Ss][Uu] [Nn][Ee]") then utilities.send_video(msg.chat.id, 'http://code.ponywave.de/workspace/test/fuck/sugoidesune.mp4', 'eeeeee!?\nSUGOI DESU NE?', msg.message_id) return