@whanext/core 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +15 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## 0.16.0
|
|
5
|
+
|
|
6
|
+
### Adicionado
|
|
7
|
+
|
|
8
|
+
- Novo evento público `messageDeleted` em `app.on()` e `multi.on()`.
|
|
9
|
+
- Novo tipo `MessageDeleted`, com chave da mensagem, payload original quando disponível, autor da revogação e horário da exclusão.
|
|
10
|
+
- O provider Baileys passa a observar `messages.update` e reconhecer revogações sem expor tipos do Baileys à aplicação.
|
|
11
|
+
- Mensagens revogadas permanecem no cache recente, permitindo `app.message.repost()` e `app.media.download()` enquanto a entrada estiver disponível.
|
|
12
|
+
|
|
13
|
+
### Compatibilidade
|
|
14
|
+
|
|
15
|
+
- A mudança é aditiva para consumidores da API pública.
|
|
16
|
+
- Providers customizados passam a incluir `messageDeleted` em `ProviderEvents`.
|
|
17
|
+
- Quando a mensagem original já saiu do cache, o evento continua sendo emitido sem o campo `message`.
|
|
18
|
+
|
|
4
19
|
## 0.15.0
|
|
5
20
|
|
|
6
21
|
### Adicionado
|
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ await app.login({
|
|
|
37
37
|
- Prefixo global e comandos declarativos com argumentos tipados.
|
|
38
38
|
- Comandos exclusivos da conta conectada com `guards.owner()` ou `onlyOwner`.
|
|
39
39
|
- Usuários normalizados entre JID, LID e PN.
|
|
40
|
-
- Mensagens, replies, edição, exclusão, menções, mídias e download normalizado.
|
|
40
|
+
- Mensagens, replies, edição, exclusão, revogações, menções, mídias e download normalizado.
|
|
41
41
|
- Operações de grupos e membros com resultados idempotentes.
|
|
42
42
|
- Cache de metadados transparente e substituível.
|
|
43
43
|
- Mute permanente ou temporário com SQLite ou banco próprio.
|
|
@@ -159,6 +159,20 @@ if (principal?.isReady) {
|
|
|
159
159
|
|
|
160
160
|
`multi.commands.command()`, `use()`, `onError()` e `load()` aplicam a mesma configuração de comandos a todas as contas. Dentro de um comando, `ctx.account.id` informa qual conta recebeu e executou aquela interação. Eventos também podem ser observados em conjunto com `multi.on()`.
|
|
161
161
|
|
|
162
|
+
## Mensagens apagadas
|
|
163
|
+
|
|
164
|
+
Revogações recebidas pelo WhatsApp são expostas pelo evento `messageDeleted`. Quando a mensagem original ainda estiver no cache recente, o payload inclui `message`, que pode ser republicada ou usada para baixar a mídia pelas APIs existentes.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
app.on('messageDeleted', async ({ message, deletedByMe }) => {
|
|
168
|
+
if (!message || deletedByMe) return;
|
|
169
|
+
|
|
170
|
+
await app.message.repost(message, app.account.selfChatId);
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
O evento também informa `deletedById` quando o WhatsApp fornece a identidade responsável pela revogação.
|
|
175
|
+
|
|
162
176
|
## Logging
|
|
163
177
|
|
|
164
178
|
O nível padrão é `info`. Estão disponíveis `debug`, `info`, `warn`, `error` e `silent`.
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,13 @@ interface QuotedMessage {
|
|
|
90
90
|
contentKind?: MessageContentKind;
|
|
91
91
|
media?: MessageMedia;
|
|
92
92
|
}
|
|
93
|
+
interface MessageDeleted {
|
|
94
|
+
key: MessageKey;
|
|
95
|
+
message?: Message;
|
|
96
|
+
deletedByMe: boolean;
|
|
97
|
+
deletedById?: string;
|
|
98
|
+
deletedAt: Date;
|
|
99
|
+
}
|
|
93
100
|
interface Message {
|
|
94
101
|
id: string;
|
|
95
102
|
jid: string;
|
|
@@ -247,6 +254,7 @@ interface ConnectionUpdate {
|
|
|
247
254
|
}
|
|
248
255
|
interface ProviderEvents {
|
|
249
256
|
message: Message;
|
|
257
|
+
messageDeleted: MessageDeleted;
|
|
250
258
|
connection: ConnectionUpdate;
|
|
251
259
|
groupChanged: {
|
|
252
260
|
groupId: string;
|
|
@@ -746,6 +754,7 @@ declare class AccountService {
|
|
|
746
754
|
|
|
747
755
|
interface AppEvents {
|
|
748
756
|
message: Message;
|
|
757
|
+
messageDeleted: MessageDeleted;
|
|
749
758
|
connection: ConnectionUpdate;
|
|
750
759
|
error: WhaNextError;
|
|
751
760
|
mute: MuteEnforcement;
|
|
@@ -905,4 +914,4 @@ declare class SqliteMuteStore implements MuteStore {
|
|
|
905
914
|
close(): void;
|
|
906
915
|
}
|
|
907
916
|
|
|
908
|
-
export { AccountService, type AddMuteOptions, type AddMuteResult, type AppEvents, type AppHealth, type AppHealthStatus, ArgsParser, type AudioContent, type BooleanOption, Browser, type ButtonsContent, type CacheOptions, type CacheStore, type CallEvent, type CallStatus, type ChangeResult, type CommandAccountContext, type CommandCatalogOptions, type CommandCatalogView, type CommandChatContext, type CommandConcurrency, type CommandContext, type CommandCooldown, type CommandDefinition, type CommandErrorHandler, type CommandGroupContext, type CommandGroupDefinition, type CommandGuard, type CommandHelpOptions, type CommandHooks, type CommandLocalization, type CommandMetadata, type CommandMiddleware, type CommandOptionDefinition, type CommandOptionSchema, type CommandOptionValue, type CommandOptionValues, type CommandRegistrar, CommandRouter, type CommandRuntimeServices, type CommandScope, type ConcurrencyStrategy, type ConnectionState, type ConnectionUpdate, type CopyCodeButton, type CreateMultiOptions, type CreateOptions, DeferredReply, type DownloadedMedia, type DurationOption, type EnumOption, type ExecutableCommandDefinition, type GroupAccess, type GroupAddressingMode, type GroupParticipant, type GroupParticipantAction, type GroupParticipantsChanged, type GroupRole, type GroupSnapshot, type GuardResult, type ImageContent, type InviteResult, type LinkButton, type LoadCommandsOptions, type LoadCommandsResult, type LoadedCommand, type LogContext, type LogEntry, type LogFormat, type LogLevel, type LogWriter, Logger, type LoggerConfig, type LoggerOptions, type LoginOptions, type MediaKind, type MediaSource, type MemberActionState, MemoryCache, type MemoryCacheStats, type MentionTarget, type Message, type MessageButton, type MessageContent, type MessageContentKind, type MessageKey, type MessageMedia, type MultiAccountOptions, type MultiAppEvent, type MultiAppHealth, MultiCommandRouter, type MultiLoadCommandsResult, type MultiLoginOptions, type MuteChangeResult, type MuteEnforcement, type MuteOptions, type MuteRecord, MuteService, type MuteStore, type NumberOption, ParsedCommandOptions, type ParticipantUpdateResult, type PresenceState, type QuotedMessage, type ReconnectOptions, type RegisteredCommand, type RemoveMuteResult, type ReplyOptions, type RepostMessageOptions, type RouterOptions, type SentMessage, SqliteMuteStore, type StickerContent, type StoredMute, type StringOption, type TextContent, User, type UserData, type UserOption, type VideoContent, WhaNextApp, WhaNextError, type WhaNextErrorCode, WhaNextMultiApp, type WhatsAppProvider, create, createMulti, defineCommand, defineCommandGroup, defineCommands, defineSubcommand, guards, isCommandGroup, loadCommands, option, toWhaNextError };
|
|
917
|
+
export { AccountService, type AddMuteOptions, type AddMuteResult, type AppEvents, type AppHealth, type AppHealthStatus, ArgsParser, type AudioContent, type BooleanOption, Browser, type ButtonsContent, type CacheOptions, type CacheStore, type CallEvent, type CallStatus, type ChangeResult, type CommandAccountContext, type CommandCatalogOptions, type CommandCatalogView, type CommandChatContext, type CommandConcurrency, type CommandContext, type CommandCooldown, type CommandDefinition, type CommandErrorHandler, type CommandGroupContext, type CommandGroupDefinition, type CommandGuard, type CommandHelpOptions, type CommandHooks, type CommandLocalization, type CommandMetadata, type CommandMiddleware, type CommandOptionDefinition, type CommandOptionSchema, type CommandOptionValue, type CommandOptionValues, type CommandRegistrar, CommandRouter, type CommandRuntimeServices, type CommandScope, type ConcurrencyStrategy, type ConnectionState, type ConnectionUpdate, type CopyCodeButton, type CreateMultiOptions, type CreateOptions, DeferredReply, type DownloadedMedia, type DurationOption, type EnumOption, type ExecutableCommandDefinition, type GroupAccess, type GroupAddressingMode, type GroupParticipant, type GroupParticipantAction, type GroupParticipantsChanged, type GroupRole, type GroupSnapshot, type GuardResult, type ImageContent, type InviteResult, type LinkButton, type LoadCommandsOptions, type LoadCommandsResult, type LoadedCommand, type LogContext, type LogEntry, type LogFormat, type LogLevel, type LogWriter, Logger, type LoggerConfig, type LoggerOptions, type LoginOptions, type MediaKind, type MediaSource, type MemberActionState, MemoryCache, type MemoryCacheStats, type MentionTarget, type Message, type MessageButton, type MessageContent, type MessageContentKind, type MessageDeleted, type MessageKey, type MessageMedia, type MultiAccountOptions, type MultiAppEvent, type MultiAppHealth, MultiCommandRouter, type MultiLoadCommandsResult, type MultiLoginOptions, type MuteChangeResult, type MuteEnforcement, type MuteOptions, type MuteRecord, MuteService, type MuteStore, type NumberOption, ParsedCommandOptions, type ParticipantUpdateResult, type PresenceState, type QuotedMessage, type ReconnectOptions, type RegisteredCommand, type RemoveMuteResult, type ReplyOptions, type RepostMessageOptions, type RouterOptions, type SentMessage, SqliteMuteStore, type StickerContent, type StoredMute, type StringOption, type TextContent, User, type UserData, type UserOption, type VideoContent, WhaNextApp, WhaNextError, type WhaNextErrorCode, WhaNextMultiApp, type WhatsAppProvider, create, createMulti, defineCommand, defineCommandGroup, defineCommands, defineSubcommand, guards, isCommandGroup, loadCommands, option, toWhaNextError };
|
package/dist/index.js
CHANGED
|
@@ -2197,6 +2197,15 @@ var WhaNextApp = class {
|
|
|
2197
2197
|
});
|
|
2198
2198
|
await this.#events.emit("call", call);
|
|
2199
2199
|
});
|
|
2200
|
+
this.#provider.on("messageDeleted", async (deletion) => {
|
|
2201
|
+
this.logger.debug("Message deleted", {
|
|
2202
|
+
chatId: deletion.key.chatId,
|
|
2203
|
+
messageId: deletion.key.id,
|
|
2204
|
+
deletedByMe: deletion.deletedByMe,
|
|
2205
|
+
cached: deletion.message !== void 0
|
|
2206
|
+
});
|
|
2207
|
+
await this.#events.emit("messageDeleted", deletion);
|
|
2208
|
+
});
|
|
2200
2209
|
this.#provider.on("message", async (message) => {
|
|
2201
2210
|
try {
|
|
2202
2211
|
const enforcement = await this.mute.enforce(message);
|
|
@@ -2848,6 +2857,23 @@ var BaileysProvider = class {
|
|
|
2848
2857
|
if (message) void this.#events.emit("message", message);
|
|
2849
2858
|
}
|
|
2850
2859
|
});
|
|
2860
|
+
socket.ev.on("messages.update", (updates) => {
|
|
2861
|
+
for (const { key, update } of updates) {
|
|
2862
|
+
if (update.message !== null || !key.id || !key.remoteJid) continue;
|
|
2863
|
+
const stored = this.#messageStore.get(this.#messageStoreKey(key));
|
|
2864
|
+
const message = stored ? normalizeBaileysMessage(stored) : void 0;
|
|
2865
|
+
const deletionKey = update.key;
|
|
2866
|
+
const deletedByMe = deletionKey?.fromMe === true;
|
|
2867
|
+
const deletedById = deletionKey?.participant ?? deletionKey?.participantAlt ?? (deletedByMe ? this.#socket?.user?.id : deletionKey?.remoteJid ?? void 0);
|
|
2868
|
+
void this.#events.emit("messageDeleted", {
|
|
2869
|
+
key: message?.keys ?? normalizeKey(key),
|
|
2870
|
+
...message ? { message } : {},
|
|
2871
|
+
deletedByMe,
|
|
2872
|
+
...deletedById ? { deletedById } : {},
|
|
2873
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
});
|
|
2851
2877
|
socket.ev.on("groups.update", (groups) => {
|
|
2852
2878
|
for (const group of groups) {
|
|
2853
2879
|
if (group.id) {
|