Nutze neue Cleverbot-API (by @Brawl345)

Plugin für Pi-Hole
Weitere kleine fixes
This commit is contained in:
Akamaru 2017-02-15 16:49:23 +01:00
parent b53c855788
commit fadd16e2c0
8 changed files with 75 additions and 25 deletions

View File

@ -59,12 +59,6 @@ Sende /hilfe, um zu starten
max_duration = 526000, max_duration = 526000,
max_reminders_group = 10, max_reminders_group = 10,
max_reminders_private = 50 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...'
} }
} }

View File

@ -6,34 +6,29 @@ function cleverbot:init(config)
"^[Mm][Ii][Kk][Uu][Bb][Oo][Tt], (.+)$", "^[Mm][Ii][Kk][Uu][Bb][Oo][Tt], (.+)$",
"^[Mm][Ii][Kk][Uu], (.+)$" "^[Mm][Ii][Kk][Uu], (.+)$"
} }
cleverbot.url = config.cleverbot.cleverbot_api
end end
cleverbot.command = 'cbot <Text>' cleverbot.command = 'cbot <Text>'
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) function cleverbot:action(msg, config, matches)
utilities.send_typing(msg.chat.id, 'typing') utilities.send_typing(msg.chat.id, 'typing')
local text = matches[1] 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 if code ~= 200 then
utilities.send_reply(msg, config.cleverbot.connection) utilities.send_reply(msg, config.errors.connection)
return return
end end
local data = json.decode(query) local data = json.decode(query)
if not data.clever then if not data.output then
utilities.send_reply(msg, config.cleverbot.response) utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...')
return return
end end
local answer = string.gsub(data.clever, "&Auml;", "Ä") utilities.send_reply(msg, data.output)
local answer = string.gsub(answer, "&auml;", "ä")
local answer = string.gsub(answer, "&Ouml;", "Ö")
local answer = string.gsub(answer, "&ouml;", "ö")
local answer = string.gsub(answer, "&Uuml;", "Ü")
local answer = string.gsub(answer, "&uuml;", "ü")
local answer = string.gsub(answer, "&szlig;", "ß")
utilities.send_reply(msg, answer)
end end
return cleverbot return cleverbot

View File

@ -39,9 +39,9 @@ function media_download:pre_process(msg, config)
elseif msg.video then elseif msg.video then
file_id = msg.video.file_id file_id = msg.video.file_id
file_size = msg.video.file_size file_size = msg.video.file_size
elseif msg.sticker then --[[elseif msg.sticker then
file_id = msg.sticker.file_id file_id = msg.sticker.file_id
file_size = msg.sticker.file_size file_size = msg.sticker.file_size]]
elseif msg.voice then elseif msg.voice then
file_id = msg.voice.file_id file_id = msg.voice.file_id
file_size = msg.voice.file_size file_size = msg.voice.file_size

View File

@ -28,7 +28,7 @@ function mal_user:get_infos(user)
end end
local pause = '<b>'..data.user_onhold..' pausiert</b>' local pause = '<b>'..data.user_onhold..' pausiert</b>'
local dropped = '<b>'..data.user_dropped..' abgebrochen</b>' local dropped = '<b>'..data.user_dropped..' abgebrochen</b>'
local complete = '<b>'..data.user_completed..' beendet</b>' local complete = '<b>'..data.user_completed..' beendet</b>'
if data.user_plantowatch == '1' then if data.user_plantowatch == '1' then
planed = '<b>'..data.user_plantowatch..'</b> steht' planed = '<b>'..data.user_plantowatch..'</b> steht'
else else

58
miku/plugins/pihole.lua Normal file
View File

@ -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 = '<b>Pi-Hole Statistik vom '..pihole:transeng(time)..'</b>\nGeblockte Domains: <i>'..domains_being_blocked..'</i>\nHeutige DNS-Abfragen: <i>'..dns_queries_today..'</i>\nGeblockte DNS-Abfragen: <i>'..ads_blocked_today..' ('..ads_percentage_today..'%)</i>'
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

View File

@ -26,7 +26,7 @@ local DESC_LENTH = 400
local plex_token = cred_data.plex_token local plex_token = cred_data.plex_token
function plex:get_plex(query) 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 response_body = {}
local request_constructor = { local request_constructor = {
url = baseurl..'/search?query='..query..'&X-Plex-Token='..plex_token, url = baseurl..'/search?query='..query..'&X-Plex-Token='..plex_token,

View File

@ -5,7 +5,7 @@ preview.command = 'preview <link>'
function preview:init(config) function preview:init(config)
preview.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('preview', true).table preview.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('preview', true).table
preview.inline_triggers = { preview.inline_triggers = {
"^pr (https?://[%w-_%.%?%.:/%+=&%~%%#]+)$" "^pr (https?://[%w-_%.%?%.,:/%+=&%~%%#]+)$"
} }
preview.doc = [[* preview.doc = [[*
]]..config.cmd_pat..[[preview* _<URL>_ ]]..config.cmd_pat..[[preview* _<URL>_

View File

@ -36,7 +36,8 @@ special.triggers = {
"^/[Ss][Cc][Hh][Ee][Ll][Ll][Ee]$", "^/[Ss][Cc][Hh][Ee][Ll][Ll][Ee]$",
"^[Pp][Ii][Nn][Gg]$", "^[Pp][Ii][Nn][Gg]$",
"^[Dd][Aa][Ss] [Ii][Ss][Tt]? [Nn][Ii][Cc][Hh][Tt]? [Ll][Uu][Ss][Tt][Ii][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 MUST CLICK
I AM A STUPID ANIMAL THAT IS ATTRACTED TO COLORS]] 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, '<a href="https://lmgtfy.com/?q='..URL.escape(matches[1])..'">Deine Antwort findest du hier.</a> ;)', 'HTML')
end end
utilities.send_reply(msg, output) utilities.send_reply(msg, output)