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/ping.lua

25 lines
536 B
Lua
Raw Normal View History

2014-12-16 21:50:19 +01:00
socket = require("socket")
function cron()
-- Use yours desired web and id
2014-12-22 22:12:28 +01:00
local addr = "www.google.com"
2014-12-22 21:43:36 +01:00
local dest = "user#id"..our_id
2014-12-22 22:12:28 +01:00
-- Checks a TCP connexion
2014-12-22 21:43:36 +01:00
local connexion = socket.connect(addr, 80)
if not connexion then
2014-12-16 21:50:19 +01:00
local text = "ALERT: "..addr.." is offline"
print (text)
send_msg(dest, text, ok_cb, false)
2014-12-22 21:43:36 +01:00
else
connexion:close()
2014-12-16 21:50:19 +01:00
end
2014-11-04 16:09:08 +01:00
end
return {
2014-12-16 21:50:19 +01:00
description = "If domain is offline, send msg to peer",
usage = "",
patterns = {},
run = nil,
cron = cron
2014-11-04 16:09:08 +01:00
}