local requests = require("requests")
local ansi_decode = {
[128]= "\208\130", [129]= "\208\131", [130]= "\226\128\154", [131]= "\209\147", [132]= "\226\128\158", [133]= "\226\128\166",
[134]= "\226\128\160", [135]= "\226\128\161", [136]= "\226\130\172", [137]= "\226\128\176", [138]= "\208\137", [139]= "\226\128\185",
[140]= "\208\138", [141]= "\208\140", [142]= "\208\139", [143]= "\208\143", [144]= "\209\146", [145]= "\226\128\152",
[146]= "\226\128\153", [147]= "\226\128\156", [148]= "\226\128\157", [149]= "\226\128\162", [150]= "\226\128\147", [151]= "\226\128\148",
[152]= "\194\152", [153]= "\226\132\162", [154]= "\209\153", [155]= "\226\128\186", [156]= "\209\154", [157]= "\209\156",
[158]= "\209\155", [159]= "\209\159", [160]= "\194\160", [161]= "\209\142", [162]= "\209\158", [163]= "\208\136",
[164]= "\194\164", [165]= "\210\144", [166]= "\194\166", [167]= "\194\167", [168]= "\208\129", [169]= "\194\169",
[170]= "\208\132", [171]= "\194\171", [172]= "\194\172", [173]= "\194\173", [174]= "\194\174", [175]= "\208\135",
[176]= "\194\176", [177]= "\194\177", [178]= "\208\134", [179]= "\209\150", [180]= "\210\145", [181]= "\194\181",
[182]= "\194\182", [183]= "\194\183", [184]= "\209\145", [185]= "\226\132\150", [186]= "\209\148", [187]= "\194\187",
[188]= "\209\152", [189]= "\208\133", [190]= "\209\149", [191]= "\209\151"
}
function AnsiToUtf8(s)
local t = {}
for i = 1, #s do
local b = s:byte(i)
if b < 128 then t[#t+1] = string.char(b)
else t[#t+1] = ansi_decode[b] or (b > 239 and "\209" .. string.char(b - 112) or (b > 191 and "\208" .. string.char(b - 48) or '_')) end
end
return table.concat(t)
end
function sendTG(message)
local url = string.format('https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s', token, chat_id, AnsiToUtf8(message))
local response = requests.get(url)
if response.status_code == 200 then print('Сообщение отправлено в Telegram')
else print('Ошибка отправки сообщения в Telegram:', response.text) end
end