RVT Chat

API and integration

Events, permissions and examples to integrate other scripts with RVT Chat.

Exports

RVT Chat registers no exports of its own and no chat commands. Integration goes through two net events. The framework bridge (identity, administration, character name) lives in open/bridge.lua, in the ChatBridge table: owner, customOwner, offlineOwner, isAdmin, characterName and registerIdentityHooks.

Events

EventDirectionUse
rvt_chat:rpcclient → server, and the reply backRuns an app operation (for example chat.list or message.send). The reply is { ok = true, data = ... } or { ok = false, error = { code, message } }.
rvt_chat:eventserver → clientRealtime events for the player who has the app open, as (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 })

Most useful realtime events

EventDataWhen
message.newMessageA new message arrived.
message.updatedMessageA message was edited.
message.deletedchatId, messageIdA message was deleted for everyone.
chat.typingchatId, accountId, stateSomeone is typing or recording audio.
presenceaccountId, onlineA contact went online or offline.
call.incomingGroupCallA group call arrived.
call.endedcallId, reasonA group call ended.
live.updatechatId, messageId, x, y, zA live location position changed.
session.resetreasonThe session was rebuilt (number change, restart).
account.suspendedsuspendedUntilThe account was suspended by moderation.
-- 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)

Permissions

Every operation requires a player identified by the bridge, an equipped number, the phone item and a non-suspended account. Only moderation needs an extra permission: the rvt_chat.admin ACE (Config.Admin.ace) or, in creative mode, the group in Config.Admin.group at the level in Config.Admin.level (empty by default, meaning nobody).

OperationWho canWhat it does
admin.reportsACE rvt_chat.admin (or Config.Admin group in creative mode)Lists reports.
admin.resolveReportACE rvt_chat.admin (or Config.Admin group in creative mode)Resolves a report, optionally suspending the account.
admin.suspendACE rvt_chat.admin (or Config.Admin group in creative mode)Suspends an account for X hours (0 lifts the suspension).
admin.auditACE rvt_chat.admin (or Config.Admin group in creative mode)Reads the audit log.
Moderation through 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;
All realtime events
-- 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)
Operations list

Operations marked idem require a unique clientId; repeating the same clientId returns the previous result without duplicating.

-- "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? }
Error codes
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