local pihole = {}
function pihole:init(config)
pihole.triggers = {'^/[Pp][Ii][Hh][Oo][Ll][ee]'}
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 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 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
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