You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.5 KiB
90 lines
2.5 KiB
6 years ago
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!DOCTYPE muclient>
|
||
|
<!-- Saved on Wednesday, August 01, 2018, 10:47 PM -->
|
||
|
<!-- MuClient version 5.06-pre -->
|
||
|
|
||
|
<!-- Plugin "Notifier" generated by Plugin Wizard -->
|
||
|
|
||
|
<muclient>
|
||
|
<plugin name="Notifier" author="Crowley" id="f99bb4b89cfa8c90ac2d03d5" language="Lua" purpose="Uses Telegram API to notify of events." save_state="y" date_written="2018-08-01 22:46:31" requires="5.06" version="1.0">
|
||
|
|
||
|
</plugin>
|
||
|
|
||
|
<!-- Script -->
|
||
|
|
||
|
|
||
|
<script>
|
||
|
<![CDATA[
|
||
|
local triggerLines = {
|
||
|
{name = "regularDouble", match = "^For the next 15 minutes experience is doubled in honor of the new superhero.", message = "Double for 15 minutes!"},
|
||
|
{name = "blessingDouble", match = "^Double experience for 10 minutes courtesy of .* daily blessing\\.", message = "Double for 10 minutes!"},
|
||
|
{name = "donationDouble", match ="\\[ 10 minutes of double exp started courtesy of donations being open \\]", message = "Double for 10 minutes!"},
|
||
|
{name = "hourDouble", match = "^For the next 60 minutes all experience is doubled!!$", message = "Hour of double!"},
|
||
|
{name = "questAlert", match = "^QUEST: You may now quest again.", message = "Quest time!"},
|
||
|
}
|
||
|
|
||
|
|
||
|
local triggerSetup = [[
|
||
|
<triggers>
|
||
|
<trigger match="%s" enabled="y" regexp="y" group="Notifier" keep_evaluating="y" sequence="100" name="%s" script="sendAlert">
|
||
|
</trigger>
|
||
|
</triggers>
|
||
|
]]
|
||
|
|
||
|
for _,v in ipairs(triggerLines) do
|
||
|
local triggerXML = string.format(triggerSetup, v.match, v.name)
|
||
|
ImportXML(triggerXML)
|
||
|
end
|
||
|
|
||
|
json = require 'json'
|
||
|
socket = require 'socket'
|
||
|
url = require 'socket.url'
|
||
|
http = require 'socket.http'
|
||
|
|
||
|
chatID = <your chat ID>
|
||
|
|
||
|
apiToken = "<your bot token>"
|
||
|
|
||
|
alertFormat = "https://api.telegram.org/" .. apiToken .. "/sendMessage?chat_id=%s&text=%s"
|
||
|
|
||
|
function url_encode(str)
|
||
|
if str then
|
||
|
str = str:gsub("\n", "\r\n")
|
||
|
str = str:gsub("([^%w %-%_%.%~])", function(c)
|
||
|
return ("%%%02X"):format(string.byte(c))
|
||
|
end)
|
||
|
str = str:gsub(" ", "+")
|
||
|
end
|
||
|
return str
|
||
|
end
|
||
|
|
||
|
function pageRequest(req, protocol)
|
||
|
async_ok, async = pcall(require, "async")
|
||
|
|
||
|
if async_ok then
|
||
|
retpage = async.request(req, protocol)
|
||
|
end
|
||
|
|
||
|
retval, page, status, headers, full_status = retpage:join()
|
||
|
retpage = nil
|
||
|
|
||
|
if status == 200 then
|
||
|
return page
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function sendAlert(name, line, wildcards)
|
||
|
for _,v in ipairs(triggerLines) do
|
||
|
if name == v.name then
|
||
|
msg = string.format(alertFormat, chatID, v.message)
|
||
|
break
|
||
|
end
|
||
|
end
|
||
|
pageRequest(msg, "HTTPS")
|
||
|
end
|
||
|
]]>
|
||
|
</script>
|
||
|
|
||
|
|
||
|
</muclient>
|