Content:MirLua/Examples/protocols

From Miranda NG
< Content:MirLua/Examples
Revision as of 00:46, 27 September 2017 by Unsane (talk | contribs) (Created page with "Switch all protocols statuses to online: {{Content:MirLua/Example|code= local protos = require('m_protocols') local ID_STATUS_OFFLINE = 40071 local ID_STATUS_ONLINE = 40072...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Switch all protocols statuses to online:

local protos = require('m_protocols')

local ID_STATUS_OFFLINE = 40071
local ID_STATUS_ONLINE = 40072

m.HookEvent('Miranda/System/ModulesLoaded', function()
  for acc in protos.Accounts() do
    if acc.IsEnabled and not acc.IsVirtual then
      local status = acc:CallService('/GetStatus')
      if (status == ID_STATUS_OFFLINE) then
        acc:CallService('/SetStatus', ID_STATUS_ONLINE)
      end
    end
  end
end)