Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Telegram informer for various things. Author: cyber01]]--
- -- [CONFIG]
- local chatid = '123456'
- local component = require("component")
- local fs = require("filesystem")
- local shell = require("shell")
- local args, options = shell.parse(...)
- if not component.isAvailable("internet") then
- print("This program requires an internet card to run.")
- os.exit()
- end
- local internet = require("internet")
- --- ========= Telegram section (past in your programm)===================
- function urlencode(str)
- if (str) then
- str = string.gsub (str, "\n", "\r\n")
- str = string.gsub (str, "([^%w ])",
- function (c) return string.format ("%%%02X", string.byte(c)) end)
- str = string.gsub (str, " ", "+")
- end
- return str
- end
- function telegramGET(chatid, text)
- local result, reason = internet.request("http://computercraft.ru/telegram.php?chatid="..chatid.."&text="..urlencode(text))
- local info = ""
- if result then
- for chunk in result do
- info = info .. chunk
- end
- end
- return info
- end
- --===============Telegram section (end)============
- answer = telegramGET(chatid, args[1])
- print('Результат отправки сообщения: ', answer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement