Lua Telegram Control SAMP [6.2 | 26.08.2023]

Как вам?

  • ⭐⭐

  • ⭐⭐⭐

  • ⭐⭐⭐⭐

  • ⭐⭐⭐⭐⭐


Результаты будут видны только после голосования.

GregoriDit

Участник
62
3
можно ли настроить это под новые уведомления аризоны или под появление заданий баттл паса?
 

Zeraks

Новичок
1
0
пишет сообщение получено не от вашего чат ид хотя я свой вписал как исправить
 

alarm0

Участник
44
3
Lua:
script_name('Telegram Notifications')

-- подключаем библиотеки
local effil = require("effil")
local encoding = require("encoding")
local imgui = require 'imgui'
local wm = require 'lib.windows.message'
local SE = require 'samp.events'
local bass = require 'lib.bass'
local inicfg = require "inicfg"

encoding.default = 'CP1251'
u8 = encoding.UTF8

direct_cfg = 'telegram_notification.ini'
cfg = inicfg.load(inicfg.load({
    settings = {
        sms = true,
        walkie_talkie = true,
        allMessage = false,
        rpNonRpChat = false,
        teleportSlap = true,
        market = true,
        report = true,
        fishing = true,
        family = true,
        chat_id = '1',
        token = '1'
    },
}, direct_cfg))
inicfg.save(cfg, direct_cfg)

sms = cfg.settings.sms
walkie_talkie = cfg.settings.walkie_talkie
allMessage = cfg.settings.allMessage
rpNonRpChat = cfg.settings.rpNonRpChat
teleportSlap = cfg.settings.teleportSlap
market = cfg.settings.market
report = cfg.settings.report
fishing = cfg.settings.fishing
family = cfg.settings.family

local updateid -- ID последнего сообщения для того чтобы не было флуда

function saveSettings()
    inicfg.save(cfg, direct_cfg)
end

function threadHandle(runner, url, args, resolve, reject)
    local t = runner(url, args)
    local r = t:get(0)
    while not r do
        r = t:get(0)
        wait(0)
    end
    local status = t:status()
    if status == 'completed' then
        local ok, result = r[1], r[2]
        if ok then resolve(result) else reject(result) end
    elseif err then
        reject(err)
    elseif status == 'canceled' then
        reject(status)
    end
    t:cancel(0)
end

function requestRunner()
    return effil.thread(function(u, a)
        local https = require 'ssl.https'
        local ok, result = pcall(https.request, u, a)
        if ok then
            return {true, result}
        else
            return {false, result}
        end
    end)
end

function async_http_request(url, args, resolve, reject)
    local runner = requestRunner()
    if not reject then reject = function() end end
    lua_thread.create(function()
        threadHandle(runner, url, args, resolve, reject)
    end)
end

function encodeUrl(str)
    str = str:gsub(' ', '%+')
    str = str:gsub('\n', '%%0A')
    return u8:encode(str, 'CP1251')
end

function sendTelegramNotification(msg) -- функция для отправки сообщения юзеру
    msg = msg:gsub('{......}', '') --тут типо убираем цвет
    msg = encodeUrl(msg) -- ну тут мы закодируем строку
    async_http_request('https://api.telegram.org/bot' .. cfg.settings.token .. '/sendMessage?chat_id=' .. cfg.settings.chat_id .. '&text='..msg,'', function(result) end) -- а тут уже отправка
end

function get_telegram_updates() -- функция получения сообщений от юзера
    while not updateid do wait(1) end -- ждем пока не узнаем последний ID
    local runner = requestRunner()
    local reject = function() end
    local args = ''
    while true do
        url = 'https://api.telegram.org/bot'..cfg.settings.token..'/getUpdates?chat_id='..cfg.settings.chat_id..'&offset=-1' -- создаем ссылку
        threadHandle(runner, url, args, function(result) processing_telegram_messages(result) end, reject)
        wait(0)
    end
end


function processing_telegram_messages(result)
    if not result then return end
   
    local proc_table = decodeJson(result)
    if not proc_table.ok then return end
   
    local res_table = proc_table.result[1]
    if not res_table then return end
    local userid = res_table.message.from.id
    local chatid = res_table.message.chat.id
    if tostring(cfg.settings.chat_id) ~= tostring(chatid) then return end
   
    if res_table.update_id == updateid then return end
    updateid = res_table.update_id
   
    local message_from_user = res_table.message.text
    if not message_from_user then return end
   
    local text = u8:decode(message_from_user)
    if text == "!sms" then
        toggleSMS()
    elseif text == "!r" then
        toggleWalkieTalkie()
    elseif text == "!all" then
        toggleAllMessage()
    elseif text == "!family" then
        toggleFamily()
    elseif text == "!report" then
        toggleReport()
    elseif text == "!fishing" then
        toggleFishing()
    elseif text == "!market" then
        toggleMarket()
    elseif text == "!rpnonrp" then
        toggleRPandNonRP()
    elseif text == "!slap" then
        toggleTeleportSlap()
    elseif text ~= "!spec" then
      sampSendChat(text)
    end
end

function toggleSMS()
    sms = not sms
    sendTelegramNotification("SMS: " .. tostring(sms) .. ".")
end

function toggleWalkieTalkie()
    walkie_talkie = not walkie_talkie
    sendTelegramNotification("Walkie-talkie: " .. tostring(walkie_talkie) .. ".")
end

function toggleAllMessage()
    allMessage = not allMessage
    sendTelegramNotification("All Message: " .. tostring(allMessage) .. ".")
end

function toggleFamily()
    family = not family
    sendTelegramNotification("Family: " .. tostring(family) .. ".")
end

function toggleRPandNonRP()
    rpNonRpChat = not rpNonRpChat
    sendTelegramNotification("RP and NonRP chat`s: " .. tostring(rpNonRpChat) .. ".")
end

function toggleTeleportSlap()
    teleportSlap = not teleportSlap
    sendTelegramNotification("Teleport and slap: " .. tostring(teleportSlap) .. ".")
end

function toggleMarket()
    market = not market
    sendTelegramNotification("Market: " .. tostring(market) .. ".")
end

function toggleReport()
    report = not report
    sendTelegramNotification("Report: " .. tostring(report) .. ".")
end

function toggleFishing()
    fishing = not fishing
    sendTelegramNotification("Fishing: " ..tostring(fishing) .. ".")
end

function getLastUpdate() -- тут мы получаем последний ID сообщения, если же у вас в коде будет настройка токена и chat_id, вызовите эту функцию для того чтоб получить последнее сообщение
    async_http_request('https://api.telegram.org/bot'..cfg.settings.token..'/getUpdates?chat_id='..cfg.settings.chat_id..'&offset=-1','',function(result)
        if result then
            local proc_table = decodeJson(result)
            if proc_table.ok then
                if #proc_table.result > 0 then
                    local res_table = proc_table.result[1]
                    if res_table then
                        updateid = res_table.update_id
                    end
                else
                    updateid = 1 -- тут зададим значение 1, если таблица будет пустая
                end
            end
        end
    end)
end

local ips = {
    Ruby = '51.83.207.243:7777',
    Emerald = '51.83.207.240:7777',
    Trilliant = '51.75.33.152:7777'
}
 
local function checkip()
    local ip, port = sampGetCurrentServerAddress()
    for key, value in pairs(ips) do
        if value == ip..':'..port then
            return true
        end
    end
    thisScript():unload()
end

function comma_value(n)
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end

function separator(text)
    if text:find("$") then
        for S in string.gmatch(text, "%$%d+") do
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
        for S in string.gmatch(text, "%d+%$") do
            S = string.sub(S, 0, #S-1)
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
    end
    return text
end

function main()
    while not isSampAvailable() do
        wait(0)
    end
    checkip()
    getLastUpdate() -- вызываем функцию получения последнего ID сообщения
 
    if not doesDirectoryExist("moonloader//config") then
        createDirectory("moonloader//config")
        saveSettings()
      end
    local main_window_state = imgui.ImBool(false)
    local chat_id = imgui.ImBuffer(tostring(cfg.settings.chat_id), 256)
    local token = imgui.ImBuffer(tostring(cfg.settings.token), 256)



    sampRegisterChatCommand("notification", function()
        main_window_state.v = not main_window_state.v
        imgui.Process = main_window_state.v
    end)


    function imgui.OnDrawFrame()
        if main_window_state.v then
            imgui.SetNextWindowSize(imgui.ImVec2(300, 360), imgui.Cond.FirstUseEver) -- меняем размер
            -- но для передачи значения по указателю - обязательно напрямую
            -- тут main_window_state передаётся функции imgui.Begin, чтобы можно было отследить закрытие окна нажатием на крестик

            local resX, resY = getScreenResolution()
            imgui.SetNextWindowPos(imgui.ImVec2(resX/2, resY/2), 2, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8"Telegram Notifications", main_window_state, imgui.WindowFlags.NoResize)
                if imgui.Checkbox(u8'RP и NonRP чаты.', imgui.ImBool(rpNonRpChat)) then
                    rpNonRpChat = not rpNonRpChat
                    cfg.settings.rpNonRpChat = rpNonRpChat
                    saveSettings()
                end
                if imgui.Checkbox(u8'SMS.', imgui.ImBool(sms)) then
                    sms = not sms
                    cfg.settings.sms = sms
                    saveSettings()
                end
                if imgui.Checkbox(u8'Рация.', imgui.ImBool(walkie_talkie)) then
                    walkie_talkie = not walkie_talkie
                    cfg.settings.walkie_talkie = walkie_talkie
                    saveSettings()
                end
                if imgui.Checkbox(u8'Все сообщения.', imgui.ImBool(allMessage)) then
                    allMessage = not allMessage
                    cfg.settings.allMessage = allMessage
                    saveSettings()
                end
                if imgui.Checkbox(u8'Телепорт/слап.', imgui.ImBool(teleportSlap)) then
                    teleportSlap = not teleportSlap
                    cfg.settings.teleportSlap = teleportSlap
                    saveSettings()
                end
                if imgui.Checkbox(u8'Уведомления рынка.', imgui.ImBool(market)) then
                    market = not market
                    cfg.settings.market = market
                    saveSettings()
                end
                if imgui.Checkbox(u8'Сообщение от администратора.', imgui.ImBool(report)) then
                    report = not report
                    cfg.settings.report = report
                    saveSettings()
                end
                if imgui.Checkbox(u8'Уведомления с рыбалки.', imgui.ImBool(fishing)) then
                    fishing = not fishing
                    cfg.settings.fishing = fishing
                    saveSettings()
                end
                if imgui.Checkbox(u8'Семейный чат.', imgui.ImBool(family)) then
                    family = not family
                    cfg.settings.family = family
                    saveSettings()
                end
                if imgui.CollapsingHeader(u8'Редактирование чатайди, токена.') then
                    imgui.LockPlayer = not imgui.LockPlayer
                    imgui.Text('Chatid: ')
                    if imgui.InputText('', chat_id) then
                        cfg.settings.chat_id = u8:decode(chat_id.v)
                        saveSettings()
                    end
                    imgui.Text('Token: ')
                    if imgui.InputText(' ', token) then
                        cfg.settings.token = u8:decode(token.v)
                        saveSettings()
                    end
                end

            imgui.End()
        end

    end

    -- Define constants for colors
    local COLOR_WALKIE_TALKIE = -1394212609
    local COLOR_REPORT = -6732289
    local COLOR_SMS = -65366
    local COLOR_MARKET = -172490497
    local COLOR_NONRP_CHAT = -859006465
    local COLOR_FAMILY = -3368449
    local COLOR_ALL = -1

    local function sendNotification(text)
        sendTelegramNotification(text)
    end

    function SE.onServerMessage(color, text)
        if (color == COLOR_WALKIE_TALKIE and walkie_talkie) or (color == COLOR_REPORT and report) or (color == COLOR_SMS and sms and text:find("SMS")) or ((text:find("Вы не можете рыбачить") or text:find("У вас нет наживки")) and fishing) then
            sendNotification(text)
        elseif (allMessage and not text:find("Вы далеко друг от друга")) then
            sendNotification(text)
        elseif (color == COLOR_MARKET and text:find("Вы продали") and market) then
            sendNotification(text ..separator("\nВаш баланс: $" .. tostring(getPlayerMoney(PLAYER_HANDLE))))
        elseif (rpNonRpChat and (color == COLOR_NONRP_CHAT or (color == COLOR_ALL and text:find("_") and text:find("-")))) then
            sendNotification(text)
        elseif color == COLOR_FAMILY and family then
            sendNotification(text)
        elseif (text:find("телепортировал Вас к себе") and teleportSlap) then
            sendNotification(text)
        end
    end

    function SE.onSetPlayerPos(position)
        local mX, mY, mZ = getCharCoordinates(playerPed)
        if (math.floor(math.abs(mZ-position.z) + 0.5) == 8 and teleportSlap) then
            sendTelegramNotification("Тебя слапнули!")
        end
    end

    lua_thread.create(get_telegram_updates) -- создаем нашу функцию получения сообщений от юзера

    while true do
        imgui.Process = main_window_state.v
        wait(0)
    end
end
привет, взял за основу твой скрипт, подредачил под себя, работало все отлично, сегодня с пустого места такие ошибки:
[ML] (error) Telegram Notifications: C:\GTA\GTA BY SR 2\moonloader\notification.lua:122: attempt to index field 'message' (a nil value)
stack traceback:
C:\GTA\GTA BY SR 2\moonloader\notification.lua: in function 'processing_telegram_messages'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:108: in function 'resolve'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:60: in function 'threadHandle'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:108: in function <C:\GTA\GTA BY SR 2\moonloader\notification.lua:101>
[ML] (error) Telegram Notifications: Script died due to an error. (72F6BBCC)
 

Vespan

loneliness
Автор темы
Проверенный
2,105
1,639
Lua:
script_name('Telegram Notifications')

-- подключаем библиотеки
local effil = require("effil")
local encoding = require("encoding")
local imgui = require 'imgui'
local wm = require 'lib.windows.message'
local SE = require 'samp.events'
local bass = require 'lib.bass'
local inicfg = require "inicfg"

encoding.default = 'CP1251'
u8 = encoding.UTF8

direct_cfg = 'telegram_notification.ini'
cfg = inicfg.load(inicfg.load({
    settings = {
        sms = true,
        walkie_talkie = true,
        allMessage = false,
        rpNonRpChat = false,
        teleportSlap = true,
        market = true,
        report = true,
        fishing = true,
        family = true,
        chat_id = '1',
        token = '1'
    },
}, direct_cfg))
inicfg.save(cfg, direct_cfg)

sms = cfg.settings.sms
walkie_talkie = cfg.settings.walkie_talkie
allMessage = cfg.settings.allMessage
rpNonRpChat = cfg.settings.rpNonRpChat
teleportSlap = cfg.settings.teleportSlap
market = cfg.settings.market
report = cfg.settings.report
fishing = cfg.settings.fishing
family = cfg.settings.family

local updateid -- ID последнего сообщения для того чтобы не было флуда

function saveSettings()
    inicfg.save(cfg, direct_cfg)
end

function threadHandle(runner, url, args, resolve, reject)
    local t = runner(url, args)
    local r = t:get(0)
    while not r do
        r = t:get(0)
        wait(0)
    end
    local status = t:status()
    if status == 'completed' then
        local ok, result = r[1], r[2]
        if ok then resolve(result) else reject(result) end
    elseif err then
        reject(err)
    elseif status == 'canceled' then
        reject(status)
    end
    t:cancel(0)
end

function requestRunner()
    return effil.thread(function(u, a)
        local https = require 'ssl.https'
        local ok, result = pcall(https.request, u, a)
        if ok then
            return {true, result}
        else
            return {false, result}
        end
    end)
end

function async_http_request(url, args, resolve, reject)
    local runner = requestRunner()
    if not reject then reject = function() end end
    lua_thread.create(function()
        threadHandle(runner, url, args, resolve, reject)
    end)
end

function encodeUrl(str)
    str = str:gsub(' ', '%+')
    str = str:gsub('\n', '%%0A')
    return u8:encode(str, 'CP1251')
end

function sendTelegramNotification(msg) -- функция для отправки сообщения юзеру
    msg = msg:gsub('{......}', '') --тут типо убираем цвет
    msg = encodeUrl(msg) -- ну тут мы закодируем строку
    async_http_request('https://api.telegram.org/bot' .. cfg.settings.token .. '/sendMessage?chat_id=' .. cfg.settings.chat_id .. '&text='..msg,'', function(result) end) -- а тут уже отправка
end

function get_telegram_updates() -- функция получения сообщений от юзера
    while not updateid do wait(1) end -- ждем пока не узнаем последний ID
    local runner = requestRunner()
    local reject = function() end
    local args = ''
    while true do
        url = 'https://api.telegram.org/bot'..cfg.settings.token..'/getUpdates?chat_id='..cfg.settings.chat_id..'&offset=-1' -- создаем ссылку
        threadHandle(runner, url, args, function(result) processing_telegram_messages(result) end, reject)
        wait(0)
    end
end


function processing_telegram_messages(result)
    if not result then return end
  
    local proc_table = decodeJson(result)
    if not proc_table.ok then return end
  
    local res_table = proc_table.result[1]
    if not res_table then return end
    local userid = res_table.message.from.id
    local chatid = res_table.message.chat.id
    if tostring(cfg.settings.chat_id) ~= tostring(chatid) then return end
  
    if res_table.update_id == updateid then return end
    updateid = res_table.update_id
  
    local message_from_user = res_table.message.text
    if not message_from_user then return end
  
    local text = u8:decode(message_from_user)
    if text == "!sms" then
        toggleSMS()
    elseif text == "!r" then
        toggleWalkieTalkie()
    elseif text == "!all" then
        toggleAllMessage()
    elseif text == "!family" then
        toggleFamily()
    elseif text == "!report" then
        toggleReport()
    elseif text == "!fishing" then
        toggleFishing()
    elseif text == "!market" then
        toggleMarket()
    elseif text == "!rpnonrp" then
        toggleRPandNonRP()
    elseif text == "!slap" then
        toggleTeleportSlap()
    elseif text ~= "!spec" then
      sampSendChat(text)
    end
end

function toggleSMS()
    sms = not sms
    sendTelegramNotification("SMS: " .. tostring(sms) .. ".")
end

function toggleWalkieTalkie()
    walkie_talkie = not walkie_talkie
    sendTelegramNotification("Walkie-talkie: " .. tostring(walkie_talkie) .. ".")
end

function toggleAllMessage()
    allMessage = not allMessage
    sendTelegramNotification("All Message: " .. tostring(allMessage) .. ".")
end

function toggleFamily()
    family = not family
    sendTelegramNotification("Family: " .. tostring(family) .. ".")
end

function toggleRPandNonRP()
    rpNonRpChat = not rpNonRpChat
    sendTelegramNotification("RP and NonRP chat`s: " .. tostring(rpNonRpChat) .. ".")
end

function toggleTeleportSlap()
    teleportSlap = not teleportSlap
    sendTelegramNotification("Teleport and slap: " .. tostring(teleportSlap) .. ".")
end

function toggleMarket()
    market = not market
    sendTelegramNotification("Market: " .. tostring(market) .. ".")
end

function toggleReport()
    report = not report
    sendTelegramNotification("Report: " .. tostring(report) .. ".")
end

function toggleFishing()
    fishing = not fishing
    sendTelegramNotification("Fishing: " ..tostring(fishing) .. ".")
end

function getLastUpdate() -- тут мы получаем последний ID сообщения, если же у вас в коде будет настройка токена и chat_id, вызовите эту функцию для того чтоб получить последнее сообщение
    async_http_request('https://api.telegram.org/bot'..cfg.settings.token..'/getUpdates?chat_id='..cfg.settings.chat_id..'&offset=-1','',function(result)
        if result then
            local proc_table = decodeJson(result)
            if proc_table.ok then
                if #proc_table.result > 0 then
                    local res_table = proc_table.result[1]
                    if res_table then
                        updateid = res_table.update_id
                    end
                else
                    updateid = 1 -- тут зададим значение 1, если таблица будет пустая
                end
            end
        end
    end)
end

local ips = {
    Ruby = '51.83.207.243:7777',
    Emerald = '51.83.207.240:7777',
    Trilliant = '51.75.33.152:7777'
}
 
local function checkip()
    local ip, port = sampGetCurrentServerAddress()
    for key, value in pairs(ips) do
        if value == ip..':'..port then
            return true
        end
    end
    thisScript():unload()
end

function comma_value(n)
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end

function separator(text)
    if text:find("$") then
        for S in string.gmatch(text, "%$%d+") do
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
        for S in string.gmatch(text, "%d+%$") do
            S = string.sub(S, 0, #S-1)
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
    end
    return text
end

function main()
    while not isSampAvailable() do
        wait(0)
    end
    checkip()
    getLastUpdate() -- вызываем функцию получения последнего ID сообщения
 
    if not doesDirectoryExist("moonloader//config") then
        createDirectory("moonloader//config")
        saveSettings()
      end
    local main_window_state = imgui.ImBool(false)
    local chat_id = imgui.ImBuffer(tostring(cfg.settings.chat_id), 256)
    local token = imgui.ImBuffer(tostring(cfg.settings.token), 256)



    sampRegisterChatCommand("notification", function()
        main_window_state.v = not main_window_state.v
        imgui.Process = main_window_state.v
    end)


    function imgui.OnDrawFrame()
        if main_window_state.v then
            imgui.SetNextWindowSize(imgui.ImVec2(300, 360), imgui.Cond.FirstUseEver) -- меняем размер
            -- но для передачи значения по указателю - обязательно напрямую
            -- тут main_window_state передаётся функции imgui.Begin, чтобы можно было отследить закрытие окна нажатием на крестик

            local resX, resY = getScreenResolution()
            imgui.SetNextWindowPos(imgui.ImVec2(resX/2, resY/2), 2, imgui.ImVec2(0.5, 0.5))

            imgui.Begin(u8"Telegram Notifications", main_window_state, imgui.WindowFlags.NoResize)
                if imgui.Checkbox(u8'RP и NonRP чаты.', imgui.ImBool(rpNonRpChat)) then
                    rpNonRpChat = not rpNonRpChat
                    cfg.settings.rpNonRpChat = rpNonRpChat
                    saveSettings()
                end
                if imgui.Checkbox(u8'SMS.', imgui.ImBool(sms)) then
                    sms = not sms
                    cfg.settings.sms = sms
                    saveSettings()
                end
                if imgui.Checkbox(u8'Рация.', imgui.ImBool(walkie_talkie)) then
                    walkie_talkie = not walkie_talkie
                    cfg.settings.walkie_talkie = walkie_talkie
                    saveSettings()
                end
                if imgui.Checkbox(u8'Все сообщения.', imgui.ImBool(allMessage)) then
                    allMessage = not allMessage
                    cfg.settings.allMessage = allMessage
                    saveSettings()
                end
                if imgui.Checkbox(u8'Телепорт/слап.', imgui.ImBool(teleportSlap)) then
                    teleportSlap = not teleportSlap
                    cfg.settings.teleportSlap = teleportSlap
                    saveSettings()
                end
                if imgui.Checkbox(u8'Уведомления рынка.', imgui.ImBool(market)) then
                    market = not market
                    cfg.settings.market = market
                    saveSettings()
                end
                if imgui.Checkbox(u8'Сообщение от администратора.', imgui.ImBool(report)) then
                    report = not report
                    cfg.settings.report = report
                    saveSettings()
                end
                if imgui.Checkbox(u8'Уведомления с рыбалки.', imgui.ImBool(fishing)) then
                    fishing = not fishing
                    cfg.settings.fishing = fishing
                    saveSettings()
                end
                if imgui.Checkbox(u8'Семейный чат.', imgui.ImBool(family)) then
                    family = not family
                    cfg.settings.family = family
                    saveSettings()
                end
                if imgui.CollapsingHeader(u8'Редактирование чатайди, токена.') then
                    imgui.LockPlayer = not imgui.LockPlayer
                    imgui.Text('Chatid: ')
                    if imgui.InputText('', chat_id) then
                        cfg.settings.chat_id = u8:decode(chat_id.v)
                        saveSettings()
                    end
                    imgui.Text('Token: ')
                    if imgui.InputText(' ', token) then
                        cfg.settings.token = u8:decode(token.v)
                        saveSettings()
                    end
                end

            imgui.End()
        end

    end

    -- Define constants for colors
    local COLOR_WALKIE_TALKIE = -1394212609
    local COLOR_REPORT = -6732289
    local COLOR_SMS = -65366
    local COLOR_MARKET = -172490497
    local COLOR_NONRP_CHAT = -859006465
    local COLOR_FAMILY = -3368449
    local COLOR_ALL = -1

    local function sendNotification(text)
        sendTelegramNotification(text)
    end

    function SE.onServerMessage(color, text)
        if (color == COLOR_WALKIE_TALKIE and walkie_talkie) or (color == COLOR_REPORT and report) or (color == COLOR_SMS and sms and text:find("SMS")) or ((text:find("Вы не можете рыбачить") or text:find("У вас нет наживки")) and fishing) then
            sendNotification(text)
        elseif (allMessage and not text:find("Вы далеко друг от друга")) then
            sendNotification(text)
        elseif (color == COLOR_MARKET and text:find("Вы продали") and market) then
            sendNotification(text ..separator("\nВаш баланс: $" .. tostring(getPlayerMoney(PLAYER_HANDLE))))
        elseif (rpNonRpChat and (color == COLOR_NONRP_CHAT or (color == COLOR_ALL and text:find("_") and text:find("-")))) then
            sendNotification(text)
        elseif color == COLOR_FAMILY and family then
            sendNotification(text)
        elseif (text:find("телепортировал Вас к себе") and teleportSlap) then
            sendNotification(text)
        end
    end

    function SE.onSetPlayerPos(position)
        local mX, mY, mZ = getCharCoordinates(playerPed)
        if (math.floor(math.abs(mZ-position.z) + 0.5) == 8 and teleportSlap) then
            sendTelegramNotification("Тебя слапнули!")
        end
    end

    lua_thread.create(get_telegram_updates) -- создаем нашу функцию получения сообщений от юзера

    while true do
        imgui.Process = main_window_state.v
        wait(0)
    end
end
привет, взял за основу твой скрипт, подредачил под себя, работало все отлично, сегодня с пустого места такие ошибки:
[ML] (error) Telegram Notifications: C:\GTA\GTA BY SR 2\moonloader\notification.lua:122: attempt to index field 'message' (a nil value)
stack traceback:
C:\GTA\GTA BY SR 2\moonloader\notification.lua: in function 'processing_telegram_messages'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:108: in function 'resolve'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:60: in function 'threadHandle'
C:\GTA\GTA BY SR 2\moonloader\notification.lua:108: in function <C:\GTA\GTA BY SR 2\moonloader\notification.lua:101>
[ML] (error) Telegram Notifications: Script died due to an error. (72F6BBCC)
attempt to index field 'message' (a nil value)
stack traceback:
что не понятного? луа не может получить информацию с таблицы message (res_table.message.chat.id)
подобную срань не пиши тут, что спиздил с моего скрипта код для своей срани и там ШОТО НЕ РАБОТАЕТ УУ
тебе сюда

 
D

deleted-user-399997

Гость
Можете дать полный пример как сделать поиск сообщения в всем чате и отправить все сообщение где был найден текст в тг? Просто в новой версии я не пойму как это сделать
 

Vespan

loneliness
Автор темы
Проверенный
2,105
1,639
в самой теме есть спойлер популярные RPC где и присуствует проверка текста в чате
Просто в новой версии я не пойму как это сделать
просто я не мать что бы за ручку каждого вести и показывать что-куда тыкать шобы оно работало
скачай старую версию где все лайтово из GITHUB'a там как раз все поймешь
 

SkenSaut

Новичок
2
0
Привет, как на новой версии сделать уведомления когда у меня купили или я скупил товар? Просто совсем непонятно там все
 

YarikVL

Известный
Проверенный
4,796
1,814
  • Нравится
Реакции: Vespan