RVT Chat

API e integração

Eventos, permissões e exemplos para integrar outros scripts ao RVT Chat.

Exports

O RVT Chat não registra exports próprios nem comandos de chat. A integração é feita por dois eventos de rede. A ponte com o framework (identidade, administração, nome do personagem) fica em open/bridge.lua, na tabela ChatBridge: owner, customOwner, offlineOwner, isAdmin, characterName e registerIdentityHooks.

Eventos

EventoDireçãoUso
rvt_chat:rpcclient → servidor, e a resposta de voltaExecuta uma operação do app (por exemplo chat.list ou message.send). A resposta é { ok = true, data = ... } ou { ok = false, error = { code, message } }.
rvt_chat:eventservidor → clientEventos em tempo real para o jogador que tem o app aberto, no formato (event, data).
-- Client side: run an operation and read the reply
local REQUEST_ID = 900000001

RegisterNetEvent("rvt_chat:rpc", function(requestId, response)
    if requestId ~= REQUEST_ID then return end -- ignore the app's own replies
    if response.ok then print(#response.data.items) else print(response.error.code) end
end)

-- session.hello already ran when the phone opened
TriggerServerEvent("rvt_chat:rpc", REQUEST_ID, "chat.list", { filter = "unread", limit = 20 })

Eventos em tempo real mais úteis

EventoDadosQuando
message.newMessageChegou uma mensagem nova.
message.updatedMessageUma mensagem foi editada.
message.deletedchatId, messageIdUma mensagem foi apagada para todos.
chat.typingchatId, accountId, stateAlguém está digitando ou gravando áudio.
presenceaccountId, onlineUm contato ficou online ou offline.
call.incomingGroupCallChegou uma chamada em grupo.
call.endedcallId, reasonUma chamada em grupo terminou.
live.updatechatId, messageId, x, y, zA posição de uma localização ao vivo mudou.
session.resetreasonA sessão foi refeita (troca de número, reinício).
account.suspendedsuspendedUntilA conta foi suspensa pela moderação.
-- Client side: observe realtime events
RegisterNetEvent("rvt_chat:event", function(event, data)
    if event == "message.new" then
        print(("new message %d in chat %d"):format(data.id, data.chatId))
    end
end)

Permissões

Qualquer operação exige um jogador identificado pela ponte, número equipado, item do telefone e conta não suspensa. Só a moderação tem permissão extra: a ACE rvt_chat.admin (Config.Admin.ace) ou, no modo creative, o grupo de Config.Admin.group com o nível de Config.Admin.level (vazio por padrão, ou seja, ninguém).

OperaçãoQuem podeO que faz
admin.reportsACE rvt_chat.admin (ou grupo de Config.Admin no modo creative)Lista as denúncias.
admin.resolveReportACE rvt_chat.admin (ou grupo de Config.Admin no modo creative)Resolve uma denúncia, com opção de suspender a conta.
admin.suspendACE rvt_chat.admin (ou grupo de Config.Admin no modo creative)Suspende uma conta por X horas (0 remove a suspensão).
admin.auditACE rvt_chat.admin (ou grupo de Config.Admin no modo creative)Lê o registro de auditoria.
Moderação por SQL
-- Suspend an account until 2030-01-01 (milliseconds since epoch)
UPDATE rvt_chat_accounts SET suspended_until = 1893456000000 WHERE phone_number = '5550002';

-- Open reports
SELECT id, target_type, target_id, reason, created_at FROM rvt_chat_reports WHERE status = 'open' ORDER BY id DESC;

-- Last moderation actions
SELECT actor_owner, action, target_type, target_id, created_at FROM rvt_chat_audit ORDER BY id DESC LIMIT 50;
Todos os eventos em tempo real
-- Server -> client events carried by "rvt_chat:event" (event, data)
session.reset          { reason }  identity_changed | number_changed | factory_reset | revoked | server_restart
message.new            Message
message.updated        Message
message.deleted        { chatId, messageId, deletedBy?, moderated? }
message.hidden         { messageIds }
message.reaction       { chatId, messageId, accountId?, emoji, mine }
message.status         { chatId, updates = { { id, status } } }
message.viewOnceOpened { chatId, messageId, accountId }
chat.updated | chat.added | chat.removed | chat.members | chat.pins | chat.cleared | chat.deleted
chat.typing            { chatId, accountId, state, ttlMs }
presence               { accountId, online, lastSeenAt? }
presence.changed | profile.updated   { accountId }
blocks.changed         { accountId, blocked }
join.requested | join.decided | community.added | community.removed | community.updated
community.linkRequested | community.linkDecided
channel.post | channel.postUpdated | channel.postDeleted | channel.updated | channel.closed | channel.role
status.new | status.deleted | status.viewed
live.update            { chatId, messageId, x, y, z, at }
live.ended             { chatId, messageId, reason }   expired|stopped|disconnected|revoked|not_member|blocked|chat_closed|deleted
call.incoming | call.updated   GroupCall
call.ended             { callId, reason }   empty|alone|timeout|chat_closed|max_duration|failed|restart
call.left              { callId, reason }   other_call when the player answered an LB call
call.signal            { callId, fromAccountId, kind, data }
account.suspended      { suspendedUntil }
notify                 { title, content, thumbnail?, avatar?, ref = { chatId } }   (handled by the bridge)
call.rejoinNative      { lbCallId }                                                (handled by the bridge)
Lista de operações

Operações marcadas idem exigem um clientId único; repetir o mesmo clientId devolve o resultado anterior sem duplicar.

-- "idem" = requires clientId (8-64 chars [A-Za-z0-9-_:]); a repeat returns the stored result with replayed = true
-- Session / profile
session.hello {}                        -> { account, settings, suspendedUntil, serverTime, capabilities, limits, syncOverlapMs }
session.bye {}                          -> { closed }
profile.me {} | profile.update { displayName?, about?, avatar? }   -- false clears a field
profile.get { accountId | number } | profile.batch { accountIds }  -- <= 100
-- Privacy / blocks / contacts
privacy.get {} | privacy.set { presence?, photo?, about?, groupsAdd?, status?, calls?, readReceipts?, notifications? }
privacy.setList { setting, accountIds }
blocks.list {} | blocks.add { accountId | number } | blocks.remove { accountId | number }
contacts.list { offset?, limit? } | contacts.search { query, limit? } | contacts.add { number, firstname, lastname? }
presence.get { accountId | accountIds }
-- Chats
chat.list { filter?, limit?, cursor? } | chat.get { chatId } | chat.openDirect { number | accountId }
chat.pin | chat.archive | chat.favorite | chat.mute { chatId, durationS (-1 forever, 0 off) } | chat.markUnread
chat.read { chatId, uptoId? } | chat.clear { chatId, keepStarred? } | chat.delete { chatId }
chat.setDisappearing { chatId, seconds } | chat.typing { chatId, state = typing|recording|idle }
chat.history { chatId, beforeId? | afterId? | aroundId?, limit? } | chat.media { chatId, kind?, beforeId?, limit? }
search.chats { query, limit? } | search.messages { query, chatId?, beforeId?, limit? }
-- Messages
message.send (idem) { chatId, clientId, kind = text|image|video|audio|sticker|gif|location|contact|poll|invite, ... }
message.get { messageId } | message.delivered { chatId, uptoId } | message.info { messageId }
message.edit { messageId, body } | message.deleteForMe { messageIds } | message.deleteForEveryone { messageId }
message.react { messageId, emoji | nil } | message.star { messageId, starred } | message.starredList { beforeAt?, limit? }
message.pin { messageId, pinned, durationS? } | poll.vote { messageId, options }
message.forward { messageIds (<= 30), chatIds (<= 5), clientId } | media.openOnce { messageId }
media.register { kind, url, mime?, size?, durationS?, width?, height?, name? } -> { mediaId, kind }
sync.since { cursor? } -> { cursor, chats, messages, hasMore, serverTime }
-- Groups
group.create (idem) { clientId, name, description?, avatar?, accountIds?, numbers? }
group.update { chatId, name?, description?, avatar?, settings? } | group.members { chatId }
group.addMembers { chatId, accountIds?, numbers? } | group.removeMember { chatId, accountId }
group.setRole { chatId, accountId, role = admin|member } | group.transferOwnership { chatId, accountId }
group.leave { chatId } | group.close { chatId }
-- Invites and join requests
invite.create { targetType = group|community|channel, targetId, ttlS?, maxUses? } | invite.list | invite.revoke { code }
invite.preview { code } | invite.join { code } -> { status = member|pending }
join.requests { targetType, targetId } | join.decide { requestId, approve } | join.cancel { requestId }
-- Communities
community.create (idem) | community.list | community.get | community.update | community.members | community.setRole
community.transferOwnership | community.removeMember | community.leave | community.close
community.linkGroup | community.linkRequests | community.unlinkGroup | community.joinGroup
-- Channels
channel.create (idem) | channel.get | channel.update | channel.close | channel.admins | channel.setAdmin
channel.transferOwnership | channel.follow | channel.unfollow | channel.notifications | channel.following
channel.discover { query?, offset?, limit? } | channel.posts | channel.post (clientId) | channel.editPost
channel.deletePost | channel.react | channel.vote
-- Broadcast lists
broadcast.create (idem) | broadcast.list | broadcast.get | broadcast.update | broadcast.delete | broadcast.send
-- Status
status.create | status.feed | status.view | status.mine | status.viewers | status.delete
status.reply { statusId, body, clientId } | status.react { statusId, emoji, clientId } | status.mute { accountId, muted }
-- Live location
live.start { chatId, clientId, durationS, label?, body? } | live.stop { messageId } | live.mine {} | location.waypoint { messageId }
-- Calls
call.start { clientId, video?, chatId | accountId | number } | call.accept | call.decline | call.join | call.leave
call.invite { callId, accountIds } | call.active { chatId } | call.media { callId, muted?, camera? }
call.signal { callId, toAccountId, kind = offer|answer|ice|renegotiate, data } | call.iceServers { callId } | call.history
-- Reports and moderation (admin.* need the ACE in Config.Admin.ace, or the group in Config.Admin.group on creative)
report.create { targetType, targetId, reason, details?, block? }
admin.reports { status?, beforeId?, limit? } | admin.resolveReport { reportId, action, resolution?, suspendHours? }
admin.suspend { accountId, hours (0 removes) } | admin.audit { beforeId?, limit? }
Códigos de erro
BAD_REQUEST        invalid payload (details.max / details.options may be present)
UNKNOWN_OP         op does not exist
PAYLOAD_TOO_LARGE  JSON payload above Config.Limits.payloadBytes
UNAUTHENTICATED    the bridge could not identify the player (no owner for the source)
NO_PHONE           no equipped number, or phone item missing
SESSION_REQUIRED   call session.hello again
SUSPENDED          account suspended (details.suspendedUntil)
FORBIDDEN          authenticated but not allowed
NOT_FOUND          missing OR not visible (same answer on purpose)
BLOCKED            you blocked the contact
CLOSED             group/community/channel/chat is closed
EXPIRED            window ended (edit, delete, invite, live location)
LIMIT_REACHED      configured limit hit (details.max)
CONFLICT           incompatible state (already linked, clientId reused elsewhere)
ALREADY_OPENED     view-once media already opened
MEDIA_REJECTED     URL, host, mime, size or duration refused
RATE_LIMITED       bucket exceeded; retry later
BUSY               you or the contact is in a call / concurrent operation
UNAVAILABLE        LB Phone, pma-voice, transport or feature unavailable
TIMEOUT            (bridge only) no server answer in 15 s
INTERNAL           server error, nothing confirmed; retry with the same clientId