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 = '<b>Pi-Hole Statistik der letzten 24h</b>\nGeblockte Domains: <i>'..domains_being_blocked..'</i>\nDNS-Abfragen: <i>'..dns_queries_today..'</i>\nGeblockte DNS-Abfragen: <i>'..ads_blocked_today..' ('..ads_percentage_today..'%)</i>'
return text
function pihole:action(msg, config, matches)
local text = pihole:get_pihole()
if not text then
utilities.send_reply(msg, config.errors.results)
return
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
return pihole