API et intégration
Événements, permissions et exemples pour intégrer d'autres scripts à RVT Chat.
Exports
RVT Chat n'enregistre aucun export propre ni commande de chat. L'intégration passe par deux événements réseau. Le pont avec le framework (identité, administration, nom du personnage) se trouve dans open/bridge.lua, dans la table ChatBridge : owner, customOwner, offlineOwner, isAdmin, characterName et registerIdentityHooks.
Événements
| Événement | Sens | Usage |
|---|---|---|
rvt_chat:rpc | client → serveur, puis la réponse en retour | Exécute une opération de l'app (par exemple chat.list ou message.send). La réponse est { ok = true, data = ... } ou { ok = false, error = { code, message } }. |
rvt_chat:event | serveur → client | Événements en temps réel pour le joueur qui a l'app ouverte, au format (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 })Événements temps réel les plus utiles
| Événement | Données | Quand |
|---|---|---|
message.new | Message | Un nouveau message est arrivé. |
message.updated | Message | Un message a été modifié. |
message.deleted | chatId, messageId | Un message a été supprimé pour tous. |
chat.typing | chatId, accountId, state | Quelqu'un écrit ou enregistre un vocal. |
presence | accountId, online | Un contact est passé en ligne ou hors ligne. |
call.incoming | GroupCall | Un appel de groupe est arrivé. |
call.ended | callId, reason | Un appel de groupe est terminé. |
live.update | chatId, messageId, x, y, z | La position d'une localisation en direct a changé. |
session.reset | reason | La session a été refaite (changement de numéro, redémarrage). |
account.suspended | suspendedUntil | Le compte a été suspendu par la modération. |
-- 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
Toute opération exige un joueur identifié par le pont, un numéro équipé, l'objet téléphone et un compte non suspendu. Seule la modération demande une permission en plus : l'ACE rvt_chat.admin (Config.Admin.ace) ou, en mode creative, le groupe de Config.Admin.group au niveau de Config.Admin.level (vide par défaut, donc personne).
| Opération | Qui peut | Rôle |
|---|---|---|
admin.reports | ACE rvt_chat.admin (ou groupe de Config.Admin en mode creative) | Liste les signalements. |
admin.resolveReport | ACE rvt_chat.admin (ou groupe de Config.Admin en mode creative) | Traite un signalement, avec option de suspendre le compte. |
admin.suspend | ACE rvt_chat.admin (ou groupe de Config.Admin en mode creative) | Suspend un compte pour X heures (0 lève la suspension). |
admin.audit | ACE rvt_chat.admin (ou groupe de Config.Admin en mode creative) | Lit le journal d'audit. |
Modération par 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;Tous les événements temps réel
-- 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)Liste des opérations
Les opérations marquées idem exigent un clientId unique ; répéter le même clientId renvoie le résultat précédent sans doublon.
-- "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? }Codes d'erreur
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