API e integración
Eventos, permisos y ejemplos para integrar otros scripts con RVT Chat.
Exports
RVT Chat no registra exports propios ni comandos de chat. La integración se hace con dos eventos de red. El puente con el framework (identidad, administración, nombre del personaje) está en open/bridge.lua, en la tabla ChatBridge: owner, customOwner, offlineOwner, isAdmin, characterName y registerIdentityHooks.
Eventos
| Evento | Dirección | Uso |
|---|---|---|
rvt_chat:rpc | cliente → servidor, y la respuesta de vuelta | Ejecuta una operación de la app (por ejemplo chat.list o message.send). La respuesta es { ok = true, data = ... } o { ok = false, error = { code, message } }. |
rvt_chat:event | servidor → cliente | Eventos en tiempo real para el jugador que tiene la app abierta, con el 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 en tiempo real más útiles
| Evento | Datos | Cuándo |
|---|---|---|
message.new | Message | Llegó un mensaje nuevo. |
message.updated | Message | Se editó un mensaje. |
message.deleted | chatId, messageId | Se borró un mensaje para todos. |
chat.typing | chatId, accountId, state | Alguien está escribiendo o grabando audio. |
presence | accountId, online | Un contacto se conectó o desconectó. |
call.incoming | GroupCall | Llegó una llamada grupal. |
call.ended | callId, reason | Terminó una llamada grupal. |
live.update | chatId, messageId, x, y, z | Cambió la posición de una ubicación en tiempo real. |
session.reset | reason | Se rehízo la sesión (cambio de número, reinicio). |
account.suspended | suspendedUntil | La moderación suspendió la cuenta. |
-- 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)Permisos
Toda operación exige un jugador identificado por el puente, número equipado, ítem del teléfono y cuenta no suspendida. Solo la moderación necesita un permiso extra: la ACE rvt_chat.admin (Config.Admin.ace) o, en modo creative, el grupo de Config.Admin.group con el nivel de Config.Admin.level (vacío por defecto, es decir, nadie).
| Operación | Quién puede | Qué hace |
|---|---|---|
admin.reports | ACE rvt_chat.admin (o grupo de Config.Admin en modo creative) | Lista las denuncias. |
admin.resolveReport | ACE rvt_chat.admin (o grupo de Config.Admin en modo creative) | Resuelve una denuncia, con opción de suspender la cuenta. |
admin.suspend | ACE rvt_chat.admin (o grupo de Config.Admin en modo creative) | Suspende una cuenta por X horas (0 quita la suspensión). |
admin.audit | ACE rvt_chat.admin (o grupo de Config.Admin en modo creative) | Lee el registro de auditoría. |
Moderación 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 los eventos en tiempo 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 operaciones
Las operaciones marcadas idem exigen un clientId único; repetir el mismo clientId devuelve el resultado anterior sin 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 error
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