D-Bot/readmes/Telegram/onmessage.lua
2015-05-30 01:45:34 +08:00

10 lines
412 B
Lua

function encodeURI(s)
s = string.gsub(s, "([^%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end)
return string.gsub(s, " ", "+")
end
function on_msg_receive (msg)
local handle = io.popen( "wget [your BOT.php url here]?to="..encodeURI(msg.to.print_name).."&from="..encodeURI(msg.from.print_name).."&text="..encodeURI(msg.text) )
local result = handle:read("*a")
handle:close()
end