Извиняюсь за долгий ответ, пришлось изрядно покопаться в требухах и немного допилить:
local schedule = require('m_schedule')
local srmm = require('m_srmm')
local msgs = require('m_message')
local icolib = require('m_icolib')
local winapi = require('winapi')
local WAIT = 2
local IDC_MESSAGE = 3012
local function split(str, limit)
local pos = 1
return function()
local res = str:sub(pos, pos + limit - 1)
if #res > 0 then
pos = pos + #res
return res
end
end
end
function get_message_area(hwnd)
local hEdit = winapi.GetDlgItem(hwnd, IDC_MESSAGE)
if (hEdit == nil) then
error("unable to find message area")
end
return hEdit
end
function get_log_message(hwnd)
local hEdit = get_message_area(hwnd)
return winapi.GetWindowText(hEdit);
end
function clear_log_message(hwnd)
local hEdit = get_message_area(hwnd)
winapi.SetWindowText(hEdit, '');
end
function send_message_by_parts(hContact, message, limit)
if #message <= limit then
msgs.Send(hContact, message)
return
end
local n = 1
local first = true
for msg in split(message, limit) do
if first then
msgs.Send(hContact, msg)
first = false
else
schedule.Wait(WAIT * n).Seconds().Do(function()
msgs.Send(hContact, msg)
end)
n = n + 1
end
end
end
local module = 'sendInParts'
local BBBF_ISCHATBUTTON = 16
local BBBF_ISIMBUTTON = 32
local BBBF_ISRSIDEBUTTON = 128
srmm.AddButton{
Module = module,
ButtonId = 1000,
Flags = BBBF_ISCHATBUTTON | BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON,
Tooltip = m.Translate('Send in parts of 1000 characters'),
Icon = icolib.AddIcon(module, 'Send in parts of 1000 characters')
}
srmm.AddButton{
Module = module,
ButtonId = 4000,
Flags = BBBF_ISCHATBUTTON | BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON,
Tooltip = m.Translate('Send in parts of 4000 characters'),
Icon = icolib.AddIcon(module, 'Send in parts of 4000 characters')
}
m.HookEvent("SRMM/ButtonsBar/ButtonPressed", function(w, l)
local bcd = CustomButtonClickData(l)
if bcd.Module ~= module then
return;
end
local message = get_log_message(bcd.hWnd)
send_message_by_parts(bcd.hContact, message, bcd.ButtonId)
clear_log_message(bcd.hWnd)
end)