-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathdata_store.ts
More file actions
45 lines (41 loc) · 1.86 KB
/
Copy pathdata_store.ts
File metadata and controls
45 lines (41 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Contact, GroupMetadata, makeInMemoryStore, WAMessage, WAMessageKey, WASocket } from 'baileys'
import { Config } from './config'
export const dataStores: Map<string, DataStore> = new Map()
export interface getDataStore {
(phone: string, config: Config): Promise<DataStore>
}
export type MessageStatus = 'scheduled'
| 'pending'
| 'without-whatsapp'
| 'invalid-phone-number'
| 'error'
| 'failed'
| 'sent'
| 'delivered'
| 'read'
| 'played'
| 'accepted'
| 'deleted'
export type DataStore = ReturnType<typeof makeInMemoryStore> & {
loadKey: (id: string) => Promise<WAMessageKey | undefined>
setKey: (id: string, key: WAMessageKey) => Promise<void>
setUnoId: (id: string, unoId: string) => Promise<void>
setImageUrl: (jid: string, url: string) => Promise<void>
getImageUrl: (jid: string) => Promise<string | undefined>
loadImageUrl: (jid: string, sock: Partial<WASocket>) => Promise<string | undefined>
setGroupMetada: (jid: string, data: GroupMetadata) => Promise<void>
getGroupMetada: (jid: string) => Promise<GroupMetadata | undefined>
setContact: (contact: Partial<Contact>) => Promise<void>
getContact: (id: string) => Promise<Contact | undefined>
loadGroupMetada: (jid: string, sock: Partial<WASocket>) => Promise<GroupMetadata | undefined>
loadUnoId: (id: string) => Promise<string | undefined>
setStatus: (id: string, status: MessageStatus) => Promise<void>
loadStatus: (id: string) => Promise<string | undefined>
getJid: (phone: string) => Promise<string | undefined>
loadJid: (phone: string, sock: WASocket) => Promise<string | undefined>
setJid: (phone: string, jid: string) => Promise<void>
setMessage: (jid: string, message: WAMessage) => Promise<void>
cleanSession: () => Promise<void>
loadTemplates(): Promise<object[]>
setTemplates(templates: string): Promise<void>
}