This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/dns.lua

41 lines
989 B
Lua
Raw Normal View History

2015-11-12 17:42:03 +01:00
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
do
local BASE_URL = 'https://jack-dns-tools.p.mashape.com/dnstools.php'
local function get_domain_data (domain)
local apikey = cred_data.x_mashape_key
local url = BASE_URL..'?_method=DNS2IP&dns='..domain..'&mashape-key='..apikey
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
local function send_domain_data(data, receiver)
if domain == data.ip then
return
else
local text = data.ip
send_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
domain = matches[1]
local data = get_domain_data(domain)
local receiver = get_receiver(msg)
send_domain_data(data, receiver)
end
return {
description = "Löst Domain nach IP auf.",
usage = "#dns [Domain]",
patterns = {"^#dns (.*)$"},
2015-11-12 17:42:03 +01:00
run = run
}
end