diff --git a/config.lua.example b/config.lua.example index a86d5c3..9088d80 100644 --- a/config.lua.example +++ b/config.lua.example @@ -59,12 +59,6 @@ Sende /hilfe, um zu starten max_duration = 526000, max_reminders_group = 10, max_reminders_private = 50 - }, - - cleverbot = { - cleverbot_api = 'https://brawlbot.tk/apis/chatter-bot-api/cleverbot.php?text=', - connection = 'Ich möchte jetzt nicht reden...', - response = 'Ich weiß nicht, was ich dazu sagen soll...' } } \ No newline at end of file diff --git a/miku/plugins/cleverbot.lua b/miku/plugins/cleverbot.lua index 0785f84..86c341f 100644 --- a/miku/plugins/cleverbot.lua +++ b/miku/plugins/cleverbot.lua @@ -6,34 +6,29 @@ function cleverbot:init(config) "^[Mm][Ii][Kk][Uu][Bb][Oo][Tt], (.+)$", "^[Mm][Ii][Kk][Uu], (.+)$" } - cleverbot.url = config.cleverbot.cleverbot_api end cleverbot.command = 'cbot ' +local BASE_URL = 'https://www.cleverbot.com/getreply' +local apikey = cred_data.cleverbot_apikey -- get your key here: https://www.cleverbot.com/api/ + function cleverbot:action(msg, config, matches) utilities.send_typing(msg.chat.id, 'typing') local text = matches[1] - local query, code = https.request(cleverbot.url..URL.escape(text)) + local query, code = https.request(BASE_URL..'?key='..apikey..'&input='..URL.escape(text)) if code ~= 200 then - utilities.send_reply(msg, config.cleverbot.connection) + utilities.send_reply(msg, config.errors.connection) return end local data = json.decode(query) - if not data.clever then - utilities.send_reply(msg, config.cleverbot.response) + if not data.output then + utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...') return end - local answer = string.gsub(data.clever, "Ä", "Ä") - local answer = string.gsub(answer, "ä", "ä") - local answer = string.gsub(answer, "Ö", "Ö") - local answer = string.gsub(answer, "ö", "ö") - local answer = string.gsub(answer, "Ü", "Ü") - local answer = string.gsub(answer, "ü", "ü") - local answer = string.gsub(answer, "ß", "ß") - utilities.send_reply(msg, answer) + utilities.send_reply(msg, data.output) end return cleverbot \ No newline at end of file diff --git a/miku/plugins/getfile.lua b/miku/plugins/getfile.lua index 1c1c94b..80eb882 100644 --- a/miku/plugins/getfile.lua +++ b/miku/plugins/getfile.lua @@ -39,9 +39,9 @@ function media_download:pre_process(msg, config) elseif msg.video then file_id = msg.video.file_id file_size = msg.video.file_size - elseif msg.sticker then + --[[elseif msg.sticker then file_id = msg.sticker.file_id - file_size = msg.sticker.file_size + file_size = msg.sticker.file_size]] elseif msg.voice then file_id = msg.voice.file_id file_size = msg.voice.file_size diff --git a/miku/plugins/mal_user.lua b/miku/plugins/mal_user.lua index 55d800d..58f0751 100644 --- a/miku/plugins/mal_user.lua +++ b/miku/plugins/mal_user.lua @@ -28,7 +28,7 @@ function mal_user:get_infos(user) end local pause = ''..data.user_onhold..' pausiert' local dropped = ''..data.user_dropped..' abgebrochen' - local complete = ''..data.user_completed..' beendet' + local complete = ''..data.user_completed..' beendet' if data.user_plantowatch == '1' then planed = ''..data.user_plantowatch..' steht' else diff --git a/miku/plugins/pihole.lua b/miku/plugins/pihole.lua new file mode 100644 index 0000000..e807eac --- /dev/null +++ b/miku/plugins/pihole.lua @@ -0,0 +1,58 @@ +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 +end + +function pihole:get_pihole() + local url = 'http://nibutani.local/admin/api.php' + local b,c = http.request(url) + 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..'%)' + return text +end + +function pihole:action(msg, config, matches) + local text = pihole:get_pihole() + if not text then + utilities.send_reply(msg, config.errors.results) + return + end + + utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') +end + +return pihole diff --git a/miku/plugins/plex.lua b/miku/plugins/plex.lua index f096027..6116579 100644 --- a/miku/plugins/plex.lua +++ b/miku/plugins/plex.lua @@ -26,7 +26,7 @@ local DESC_LENTH = 400 local plex_token = cred_data.plex_token function plex:get_plex(query) - local baseurl = 'http://kyouko.local:32400' --replace it with yours + local baseurl = 'http://hakase.local:32400' --replace it with yours local response_body = {} local request_constructor = { url = baseurl..'/search?query='..query..'&X-Plex-Token='..plex_token, diff --git a/miku/plugins/preview.lua b/miku/plugins/preview.lua index a4fcff1..57615a0 100644 --- a/miku/plugins/preview.lua +++ b/miku/plugins/preview.lua @@ -5,7 +5,7 @@ preview.command = 'preview ' function preview:init(config) preview.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('preview', true).table preview.inline_triggers = { - "^pr (https?://[%w-_%.%?%.:/%+=&%~%%#]+)$" + "^pr (https?://[%w-_%.%?%.,:/%+=&%~%%#]+)$" } preview.doc = [[* ]]..config.cmd_pat..[[preview* __ diff --git a/miku/plugins/special.lua b/miku/plugins/special.lua index 2a16822..09cac00 100644 --- a/miku/plugins/special.lua +++ b/miku/plugins/special.lua @@ -36,7 +36,8 @@ special.triggers = { "^/[Ss][Cc][Hh][Ee][Ll][Ll][Ee]$", "^[Pp][Ii][Nn][Gg]$", "^[Dd][Aa][Ss] [Ii][Ss][Tt]? [Nn][Ii][Cc][Hh][Tt]? [Ll][Uu][Ss][Tt][Ii][Gg]!?$", - "/[Bb][Ll][Uu][Ee][Tt][Ee][Xx][Tt]" + "/[Bb][Ll][Uu][Ee][Tt][Ee][Xx][Tt]", + "/[Ll][Mm][Gg][Tt][Ff][Yy] (.*)" } @@ -139,6 +140,8 @@ function special:action(msg, config, matches) MUST CLICK I AM A STUPID ANIMAL THAT IS ATTRACTED TO COLORS]] + elseif msg_text:match("/[Ll][Mm][Gg][Tt][Ff][Yy]") then + utilities.send_reply(msg, 'Deine Antwort findest du hier. ;)', 'HTML') end utilities.send_reply(msg, output)