baileys-joss 1.0.1 → 1.0.2
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/README.md +1983 -79
- package/lib/Socket/business.d.ts +4 -0
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/chats.d.ts +4 -0
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +44 -1
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +4 -0
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/groups.d.ts +4 -0
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/index.d.ts +4 -0
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/messages-recv.d.ts +4 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-send.d.ts +4 -0
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/newsletter.d.ts +4 -0
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +4 -0
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Utils/activity-logger.d.ts +189 -0
- package/lib/Utils/activity-logger.d.ts.map +1 -0
- package/lib/Utils/activity-logger.js +418 -0
- package/lib/Utils/activity-logger.js.map +1 -0
- package/lib/Utils/anti-spam.d.ts +145 -0
- package/lib/Utils/anti-spam.d.ts.map +1 -0
- package/lib/Utils/anti-spam.js +398 -0
- package/lib/Utils/anti-spam.js.map +1 -0
- package/lib/Utils/auto-reply.d.ts +123 -0
- package/lib/Utils/auto-reply.d.ts.map +1 -0
- package/lib/Utils/auto-reply.js +234 -0
- package/lib/Utils/auto-reply.js.map +1 -0
- package/lib/Utils/broadcast.d.ts +121 -0
- package/lib/Utils/broadcast.d.ts.map +1 -0
- package/lib/Utils/broadcast.js +223 -0
- package/lib/Utils/broadcast.js.map +1 -0
- package/lib/Utils/bulk-messaging.d.ts +79 -0
- package/lib/Utils/bulk-messaging.d.ts.map +1 -0
- package/lib/Utils/bulk-messaging.js +148 -0
- package/lib/Utils/bulk-messaging.js.map +1 -0
- package/lib/Utils/chat-analytics.d.ts +92 -0
- package/lib/Utils/chat-analytics.d.ts.map +1 -0
- package/lib/Utils/chat-analytics.js +337 -0
- package/lib/Utils/chat-analytics.js.map +1 -0
- package/lib/Utils/chat-control.d.ts +156 -0
- package/lib/Utils/chat-control.d.ts.map +1 -0
- package/lib/Utils/chat-control.js +224 -0
- package/lib/Utils/chat-control.js.map +1 -0
- package/lib/Utils/chat-export.d.ts +75 -0
- package/lib/Utils/chat-export.d.ts.map +1 -0
- package/lib/Utils/chat-export.js +309 -0
- package/lib/Utils/chat-export.js.map +1 -0
- package/lib/Utils/content-detector.d.ts +199 -0
- package/lib/Utils/content-detector.d.ts.map +1 -0
- package/lib/Utils/content-detector.js +442 -0
- package/lib/Utils/content-detector.js.map +1 -0
- package/lib/Utils/index.d.ts +23 -0
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +52 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-scanner.d.ts +112 -0
- package/lib/Utils/link-scanner.d.ts.map +1 -0
- package/lib/Utils/link-scanner.js +433 -0
- package/lib/Utils/link-scanner.js.map +1 -0
- package/lib/Utils/media-downloader.d.ts +86 -0
- package/lib/Utils/media-downloader.d.ts.map +1 -0
- package/lib/Utils/media-downloader.js +269 -0
- package/lib/Utils/media-downloader.js.map +1 -0
- package/lib/Utils/meme-generator.d.ts +96 -0
- package/lib/Utils/meme-generator.d.ts.map +1 -0
- package/lib/Utils/meme-generator.js +368 -0
- package/lib/Utils/meme-generator.js.map +1 -0
- package/lib/Utils/message-search.d.ts +96 -0
- package/lib/Utils/message-search.d.ts.map +1 -0
- package/lib/Utils/message-search.js +261 -0
- package/lib/Utils/message-search.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +20 -1
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +100 -5
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +9 -2
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/mini-games.d.ts +155 -0
- package/lib/Utils/mini-games.d.ts.map +1 -0
- package/lib/Utils/mini-games.js +445 -0
- package/lib/Utils/mini-games.js.map +1 -0
- package/lib/Utils/pomodoro.d.ts +139 -0
- package/lib/Utils/pomodoro.d.ts.map +1 -0
- package/lib/Utils/pomodoro.js +434 -0
- package/lib/Utils/pomodoro.js.map +1 -0
- package/lib/Utils/qr-generator.d.ts +95 -0
- package/lib/Utils/qr-generator.d.ts.map +1 -0
- package/lib/Utils/qr-generator.js +226 -0
- package/lib/Utils/qr-generator.js.map +1 -0
- package/lib/Utils/quotes.d.ts +110 -0
- package/lib/Utils/quotes.d.ts.map +1 -0
- package/lib/Utils/quotes.js +325 -0
- package/lib/Utils/quotes.js.map +1 -0
- package/lib/Utils/scheduling.d.ts +88 -0
- package/lib/Utils/scheduling.d.ts.map +1 -0
- package/lib/Utils/scheduling.js +163 -0
- package/lib/Utils/scheduling.js.map +1 -0
- package/lib/Utils/status-posting.d.ts +151 -0
- package/lib/Utils/status-posting.d.ts.map +1 -0
- package/lib/Utils/status-posting.js +162 -0
- package/lib/Utils/status-posting.js.map +1 -0
- package/lib/Utils/templates.d.ts +154 -0
- package/lib/Utils/templates.d.ts.map +1 -0
- package/lib/Utils/templates.js +368 -0
- package/lib/Utils/templates.js.map +1 -0
- package/lib/Utils/vcard.d.ts +86 -0
- package/lib/Utils/vcard.d.ts.map +1 -0
- package/lib/Utils/vcard.js +195 -0
- package/lib/Utils/vcard.js.map +1 -0
- package/lib/Utils/voice-note.d.ts +115 -0
- package/lib/Utils/voice-note.d.ts.map +1 -0
- package/lib/Utils/voice-note.js +212 -0
- package/lib/Utils/voice-note.js.map +1 -0
- package/lib/Utils/weather.d.ts +118 -0
- package/lib/Utils/weather.d.ts.map +1 -0
- package/lib/Utils/weather.js +362 -0
- package/lib/Utils/weather.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baileys-Joss: Message Templates System
|
|
3
|
+
*
|
|
4
|
+
* Template pesan siap pakai untuk berbagai keperluan
|
|
5
|
+
*/
|
|
6
|
+
export interface TemplateVariable {
|
|
7
|
+
name: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface MessageTemplate {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
content: string;
|
|
16
|
+
variables: TemplateVariable[];
|
|
17
|
+
category?: string;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
}
|
|
21
|
+
export interface TemplateData {
|
|
22
|
+
[key: string]: string | number | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Message Template Manager
|
|
26
|
+
*/
|
|
27
|
+
export declare class TemplateManager {
|
|
28
|
+
private templates;
|
|
29
|
+
/**
|
|
30
|
+
* Generate unique ID
|
|
31
|
+
*/
|
|
32
|
+
private generateId;
|
|
33
|
+
/**
|
|
34
|
+
* Extract variables from template string
|
|
35
|
+
* Variables are in format: {{variableName}}
|
|
36
|
+
*/
|
|
37
|
+
private extractVariables;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new template
|
|
40
|
+
*/
|
|
41
|
+
create(options: {
|
|
42
|
+
name: string;
|
|
43
|
+
content: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
category?: string;
|
|
46
|
+
id?: string;
|
|
47
|
+
}): MessageTemplate;
|
|
48
|
+
/**
|
|
49
|
+
* Get a template by ID
|
|
50
|
+
*/
|
|
51
|
+
get(id: string): MessageTemplate | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get template by name
|
|
54
|
+
*/
|
|
55
|
+
getByName(name: string): MessageTemplate | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get all templates
|
|
58
|
+
*/
|
|
59
|
+
getAll(): MessageTemplate[];
|
|
60
|
+
/**
|
|
61
|
+
* Get templates by category
|
|
62
|
+
*/
|
|
63
|
+
getByCategory(category: string): MessageTemplate[];
|
|
64
|
+
/**
|
|
65
|
+
* Update a template
|
|
66
|
+
*/
|
|
67
|
+
update(id: string, updates: Partial<Omit<MessageTemplate, 'id' | 'createdAt'>>): MessageTemplate | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Delete a template
|
|
70
|
+
*/
|
|
71
|
+
delete(id: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Render template with data
|
|
74
|
+
*/
|
|
75
|
+
render(id: string, data?: TemplateData): string;
|
|
76
|
+
/**
|
|
77
|
+
* Render template content with data
|
|
78
|
+
*/
|
|
79
|
+
renderContent(content: string, data?: TemplateData): string;
|
|
80
|
+
/**
|
|
81
|
+
* Validate data against template
|
|
82
|
+
*/
|
|
83
|
+
validate(id: string, data: TemplateData): {
|
|
84
|
+
valid: boolean;
|
|
85
|
+
missing: string[];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Export templates to JSON
|
|
89
|
+
*/
|
|
90
|
+
export(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Import templates from JSON
|
|
93
|
+
*/
|
|
94
|
+
import(json: string, overwrite?: boolean): number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Pre-built templates
|
|
98
|
+
*/
|
|
99
|
+
export declare const PRESET_TEMPLATES: {
|
|
100
|
+
ORDER_CONFIRMATION: {
|
|
101
|
+
name: string;
|
|
102
|
+
category: string;
|
|
103
|
+
content: string;
|
|
104
|
+
};
|
|
105
|
+
ORDER_SHIPPED: {
|
|
106
|
+
name: string;
|
|
107
|
+
category: string;
|
|
108
|
+
content: string;
|
|
109
|
+
};
|
|
110
|
+
INVOICE: {
|
|
111
|
+
name: string;
|
|
112
|
+
category: string;
|
|
113
|
+
content: string;
|
|
114
|
+
};
|
|
115
|
+
WELCOME: {
|
|
116
|
+
name: string;
|
|
117
|
+
category: string;
|
|
118
|
+
content: string;
|
|
119
|
+
};
|
|
120
|
+
BIRTHDAY: {
|
|
121
|
+
name: string;
|
|
122
|
+
category: string;
|
|
123
|
+
content: string;
|
|
124
|
+
};
|
|
125
|
+
REMINDER: {
|
|
126
|
+
name: string;
|
|
127
|
+
category: string;
|
|
128
|
+
content: string;
|
|
129
|
+
};
|
|
130
|
+
APPOINTMENT: {
|
|
131
|
+
name: string;
|
|
132
|
+
category: string;
|
|
133
|
+
content: string;
|
|
134
|
+
};
|
|
135
|
+
SUPPORT_TICKET: {
|
|
136
|
+
name: string;
|
|
137
|
+
category: string;
|
|
138
|
+
content: string;
|
|
139
|
+
};
|
|
140
|
+
SUPPORT_RESOLVED: {
|
|
141
|
+
name: string;
|
|
142
|
+
category: string;
|
|
143
|
+
content: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Create a template manager with preset templates
|
|
148
|
+
*/
|
|
149
|
+
export declare const createTemplateManager: (includePresets?: boolean) => TemplateManager;
|
|
150
|
+
/**
|
|
151
|
+
* Quick template rendering without manager
|
|
152
|
+
*/
|
|
153
|
+
export declare const renderTemplate: (content: string, data?: TemplateData) => string;
|
|
154
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/Utils/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACp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AC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,GAAG,MAAM;IAa/D;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAmB/E;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,MAAM;CAkB/C;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmK5B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,wBAAqB,KAAG,eAa7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,OAAM,YAAiB,KAAG,MAWzE,CAAA"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baileys-Joss: Message Templates System
|
|
3
|
+
*
|
|
4
|
+
* Template pesan siap pakai untuk berbagai keperluan
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Message Template Manager
|
|
8
|
+
*/
|
|
9
|
+
export class TemplateManager {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.templates = new Map();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate unique ID
|
|
15
|
+
*/
|
|
16
|
+
generateId() {
|
|
17
|
+
return `tpl_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extract variables from template string
|
|
21
|
+
* Variables are in format: {{variableName}}
|
|
22
|
+
*/
|
|
23
|
+
extractVariables(content) {
|
|
24
|
+
const regex = /\{\{(\w+)(?::([^}]*))?\}\}/g;
|
|
25
|
+
const variables = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
let match;
|
|
28
|
+
while ((match = regex.exec(content)) !== null) {
|
|
29
|
+
const name = match[1];
|
|
30
|
+
if (!name)
|
|
31
|
+
continue;
|
|
32
|
+
const defaultValue = match[2];
|
|
33
|
+
if (!seen.has(name)) {
|
|
34
|
+
seen.add(name);
|
|
35
|
+
variables.push({
|
|
36
|
+
name,
|
|
37
|
+
defaultValue,
|
|
38
|
+
required: !defaultValue
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return variables;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a new template
|
|
46
|
+
*/
|
|
47
|
+
create(options) {
|
|
48
|
+
const template = {
|
|
49
|
+
id: options.id ?? this.generateId(),
|
|
50
|
+
name: options.name,
|
|
51
|
+
content: options.content,
|
|
52
|
+
description: options.description,
|
|
53
|
+
category: options.category,
|
|
54
|
+
variables: this.extractVariables(options.content),
|
|
55
|
+
createdAt: new Date(),
|
|
56
|
+
updatedAt: new Date()
|
|
57
|
+
};
|
|
58
|
+
this.templates.set(template.id, template);
|
|
59
|
+
return template;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get a template by ID
|
|
63
|
+
*/
|
|
64
|
+
get(id) {
|
|
65
|
+
return this.templates.get(id);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get template by name
|
|
69
|
+
*/
|
|
70
|
+
getByName(name) {
|
|
71
|
+
return Array.from(this.templates.values()).find(t => t.name === name);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get all templates
|
|
75
|
+
*/
|
|
76
|
+
getAll() {
|
|
77
|
+
return Array.from(this.templates.values());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get templates by category
|
|
81
|
+
*/
|
|
82
|
+
getByCategory(category) {
|
|
83
|
+
return Array.from(this.templates.values()).filter(t => t.category === category);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update a template
|
|
87
|
+
*/
|
|
88
|
+
update(id, updates) {
|
|
89
|
+
const template = this.templates.get(id);
|
|
90
|
+
if (!template)
|
|
91
|
+
return undefined;
|
|
92
|
+
if (updates.content) {
|
|
93
|
+
updates.variables = this.extractVariables(updates.content);
|
|
94
|
+
}
|
|
95
|
+
const updated = {
|
|
96
|
+
...template,
|
|
97
|
+
...updates,
|
|
98
|
+
updatedAt: new Date()
|
|
99
|
+
};
|
|
100
|
+
this.templates.set(id, updated);
|
|
101
|
+
return updated;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a template
|
|
105
|
+
*/
|
|
106
|
+
delete(id) {
|
|
107
|
+
return this.templates.delete(id);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Render template with data
|
|
111
|
+
*/
|
|
112
|
+
render(id, data = {}) {
|
|
113
|
+
const template = this.templates.get(id);
|
|
114
|
+
if (!template) {
|
|
115
|
+
throw new Error(`Template not found: ${id}`);
|
|
116
|
+
}
|
|
117
|
+
return this.renderContent(template.content, data);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Render template content with data
|
|
121
|
+
*/
|
|
122
|
+
renderContent(content, data = {}) {
|
|
123
|
+
return content.replace(/\{\{(\w+)(?::([^}]*))?\}\}/g, (match, name, defaultValue) => {
|
|
124
|
+
const value = data[name];
|
|
125
|
+
if (value !== undefined && value !== null) {
|
|
126
|
+
return String(value);
|
|
127
|
+
}
|
|
128
|
+
if (defaultValue !== undefined) {
|
|
129
|
+
return defaultValue;
|
|
130
|
+
}
|
|
131
|
+
return match;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Validate data against template
|
|
136
|
+
*/
|
|
137
|
+
validate(id, data) {
|
|
138
|
+
const template = this.templates.get(id);
|
|
139
|
+
if (!template) {
|
|
140
|
+
throw new Error(`Template not found: ${id}`);
|
|
141
|
+
}
|
|
142
|
+
const missing = [];
|
|
143
|
+
for (const variable of template.variables) {
|
|
144
|
+
if (variable.required && !(variable.name in data)) {
|
|
145
|
+
missing.push(variable.name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
valid: missing.length === 0,
|
|
150
|
+
missing
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Export templates to JSON
|
|
155
|
+
*/
|
|
156
|
+
export() {
|
|
157
|
+
return JSON.stringify(Array.from(this.templates.values()), null, 2);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Import templates from JSON
|
|
161
|
+
*/
|
|
162
|
+
import(json, overwrite = false) {
|
|
163
|
+
const templates = JSON.parse(json);
|
|
164
|
+
let imported = 0;
|
|
165
|
+
for (const template of templates) {
|
|
166
|
+
if (!overwrite && this.templates.has(template.id)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
this.templates.set(template.id, {
|
|
170
|
+
...template,
|
|
171
|
+
createdAt: new Date(template.createdAt),
|
|
172
|
+
updatedAt: new Date(template.updatedAt)
|
|
173
|
+
});
|
|
174
|
+
imported++;
|
|
175
|
+
}
|
|
176
|
+
return imported;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Pre-built templates
|
|
181
|
+
*/
|
|
182
|
+
export const PRESET_TEMPLATES = {
|
|
183
|
+
// Order Templates
|
|
184
|
+
ORDER_CONFIRMATION: {
|
|
185
|
+
name: 'Order Confirmation',
|
|
186
|
+
category: 'order',
|
|
187
|
+
content: `✅ *Order Confirmed!*
|
|
188
|
+
|
|
189
|
+
Order ID: #{{orderId}}
|
|
190
|
+
Customer: {{customerName}}
|
|
191
|
+
Date: {{orderDate}}
|
|
192
|
+
|
|
193
|
+
📦 *Items:*
|
|
194
|
+
{{items}}
|
|
195
|
+
|
|
196
|
+
💰 *Total: Rp {{total}}*
|
|
197
|
+
|
|
198
|
+
Thank you for your order! 🙏`
|
|
199
|
+
},
|
|
200
|
+
ORDER_SHIPPED: {
|
|
201
|
+
name: 'Order Shipped',
|
|
202
|
+
category: 'order',
|
|
203
|
+
content: `📦 *Your Order is On The Way!*
|
|
204
|
+
|
|
205
|
+
Order ID: #{{orderId}}
|
|
206
|
+
Tracking: {{trackingNumber}}
|
|
207
|
+
Courier: {{courier}}
|
|
208
|
+
|
|
209
|
+
Estimated delivery: {{estimatedDate}}
|
|
210
|
+
|
|
211
|
+
Track your package: {{trackingUrl:}}`
|
|
212
|
+
},
|
|
213
|
+
// Invoice Templates
|
|
214
|
+
INVOICE: {
|
|
215
|
+
name: 'Invoice',
|
|
216
|
+
category: 'invoice',
|
|
217
|
+
content: `📄 *INVOICE*
|
|
218
|
+
|
|
219
|
+
Invoice #: {{invoiceNumber}}
|
|
220
|
+
Date: {{invoiceDate}}
|
|
221
|
+
Due Date: {{dueDate}}
|
|
222
|
+
|
|
223
|
+
*Bill To:*
|
|
224
|
+
{{customerName}}
|
|
225
|
+
{{customerAddress:}}
|
|
226
|
+
|
|
227
|
+
*Items:*
|
|
228
|
+
{{items}}
|
|
229
|
+
|
|
230
|
+
Subtotal: Rp {{subtotal}}
|
|
231
|
+
Tax ({{taxRate:11}}%): Rp {{tax}}
|
|
232
|
+
*Total: Rp {{total}}*
|
|
233
|
+
|
|
234
|
+
Payment Method: {{paymentMethod:Transfer Bank}}
|
|
235
|
+
Account: {{bankAccount:}}`
|
|
236
|
+
},
|
|
237
|
+
// Greeting Templates
|
|
238
|
+
WELCOME: {
|
|
239
|
+
name: 'Welcome Message',
|
|
240
|
+
category: 'greeting',
|
|
241
|
+
content: `👋 *Welcome, {{name}}!*
|
|
242
|
+
|
|
243
|
+
Thank you for joining {{companyName:us}}!
|
|
244
|
+
|
|
245
|
+
We're excited to have you. Here's what you can do:
|
|
246
|
+
{{features:- Explore our products
|
|
247
|
+
- Get exclusive offers
|
|
248
|
+
- 24/7 support}}
|
|
249
|
+
|
|
250
|
+
Need help? Just reply to this message!`
|
|
251
|
+
},
|
|
252
|
+
BIRTHDAY: {
|
|
253
|
+
name: 'Birthday Wishes',
|
|
254
|
+
category: 'greeting',
|
|
255
|
+
content: `🎂 *Happy Birthday, {{name}}!* 🎉
|
|
256
|
+
|
|
257
|
+
Wishing you a wonderful day filled with joy and happiness!
|
|
258
|
+
|
|
259
|
+
🎁 As a special gift, here's {{discount:10}}% off your next purchase!
|
|
260
|
+
Use code: {{code:BIRTHDAY{{year}}}}
|
|
261
|
+
|
|
262
|
+
Have a great celebration! 🥳`
|
|
263
|
+
},
|
|
264
|
+
// Notification Templates
|
|
265
|
+
REMINDER: {
|
|
266
|
+
name: 'Reminder',
|
|
267
|
+
category: 'notification',
|
|
268
|
+
content: `⏰ *Reminder*
|
|
269
|
+
|
|
270
|
+
Hi {{name}},
|
|
271
|
+
|
|
272
|
+
This is a friendly reminder about:
|
|
273
|
+
📋 {{subject}}
|
|
274
|
+
|
|
275
|
+
📅 Date: {{date}}
|
|
276
|
+
🕐 Time: {{time}}
|
|
277
|
+
📍 Location: {{location:TBD}}
|
|
278
|
+
|
|
279
|
+
{{notes:}}
|
|
280
|
+
|
|
281
|
+
Don't forget! 🙏`
|
|
282
|
+
},
|
|
283
|
+
APPOINTMENT: {
|
|
284
|
+
name: 'Appointment Confirmation',
|
|
285
|
+
category: 'notification',
|
|
286
|
+
content: `📅 *Appointment Confirmed*
|
|
287
|
+
|
|
288
|
+
Hi {{name}},
|
|
289
|
+
|
|
290
|
+
Your appointment has been scheduled:
|
|
291
|
+
|
|
292
|
+
📋 Service: {{service}}
|
|
293
|
+
📅 Date: {{date}}
|
|
294
|
+
🕐 Time: {{time}}
|
|
295
|
+
📍 Location: {{location}}
|
|
296
|
+
|
|
297
|
+
Please arrive 10 minutes early.
|
|
298
|
+
|
|
299
|
+
Need to reschedule? Reply to this message.`
|
|
300
|
+
},
|
|
301
|
+
// Support Templates
|
|
302
|
+
SUPPORT_TICKET: {
|
|
303
|
+
name: 'Support Ticket',
|
|
304
|
+
category: 'support',
|
|
305
|
+
content: `🎫 *Support Ticket Created*
|
|
306
|
+
|
|
307
|
+
Ticket #: {{ticketId}}
|
|
308
|
+
Subject: {{subject}}
|
|
309
|
+
Priority: {{priority:Normal}}
|
|
310
|
+
|
|
311
|
+
Hi {{name}},
|
|
312
|
+
|
|
313
|
+
We've received your request and our team is working on it.
|
|
314
|
+
|
|
315
|
+
Expected response time: {{responseTime:24 hours}}
|
|
316
|
+
|
|
317
|
+
Thank you for your patience! 🙏`
|
|
318
|
+
},
|
|
319
|
+
SUPPORT_RESOLVED: {
|
|
320
|
+
name: 'Support Resolved',
|
|
321
|
+
category: 'support',
|
|
322
|
+
content: `✅ *Issue Resolved*
|
|
323
|
+
|
|
324
|
+
Ticket #: {{ticketId}}
|
|
325
|
+
|
|
326
|
+
Hi {{name}},
|
|
327
|
+
|
|
328
|
+
Your issue has been resolved:
|
|
329
|
+
|
|
330
|
+
*Solution:*
|
|
331
|
+
{{solution}}
|
|
332
|
+
|
|
333
|
+
If you need further assistance, please reply to this message.
|
|
334
|
+
|
|
335
|
+
Thank you! 🙏`
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Create a template manager with preset templates
|
|
340
|
+
*/
|
|
341
|
+
export const createTemplateManager = (includePresets = true) => {
|
|
342
|
+
const manager = new TemplateManager();
|
|
343
|
+
if (includePresets) {
|
|
344
|
+
for (const [key, template] of Object.entries(PRESET_TEMPLATES)) {
|
|
345
|
+
manager.create({
|
|
346
|
+
...template,
|
|
347
|
+
id: key.toLowerCase()
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return manager;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Quick template rendering without manager
|
|
355
|
+
*/
|
|
356
|
+
export const renderTemplate = (content, data = {}) => {
|
|
357
|
+
return content.replace(/\{\{(\w+)(?::([^}]*))?\}\}/g, (match, name, defaultValue) => {
|
|
358
|
+
const value = data[name];
|
|
359
|
+
if (value !== undefined && value !== null) {
|
|
360
|
+
return String(value);
|
|
361
|
+
}
|
|
362
|
+
if (defaultValue !== undefined) {
|
|
363
|
+
return defaultValue;
|
|
364
|
+
}
|
|
365
|
+
return match;
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/Utils/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QACS,cAAS,GAAiC,IAAI,GAAG,EAAE,CAAA;IAoM5D,CAAC;IAlMA;;OAEG;IACK,UAAU;QACjB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,OAAe;QACvC,MAAM,KAAK,GAAG,6BAA6B,CAAA;QAC3C,MAAM,SAAS,GAAuB,EAAE,CAAA;QACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;QAC9B,IAAI,KAAK,CAAA;QAET,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YACrB,IAAI,CAAC,IAAI;gBAAE,SAAQ;YACnB,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YAE7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBACd,SAAS,CAAC,IAAI,CAAC;oBACd,IAAI;oBACJ,YAAY;oBACZ,QAAQ,EAAE,CAAC,YAAY;iBACvB,C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ChC,OAAO,YAAY,CAAA;QACpB,CAAC;QACD,OAAO,KAAK,CAAA;IACb,CAAC,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baileys-Joss: vCard / Contact Card Generator
|
|
3
|
+
*
|
|
4
|
+
* Fitur untuk membuat dan mengirim kartu kontak
|
|
5
|
+
*/
|
|
6
|
+
export interface VCardContact {
|
|
7
|
+
/** Full name */
|
|
8
|
+
fullName: string;
|
|
9
|
+
/** Display name (optional) */
|
|
10
|
+
displayName?: string;
|
|
11
|
+
/** Organization/Company */
|
|
12
|
+
organization?: string;
|
|
13
|
+
/** Title/Position */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Phone numbers */
|
|
16
|
+
phones?: Array<{
|
|
17
|
+
number: string;
|
|
18
|
+
type?: 'CELL' | 'WORK' | 'HOME' | 'MAIN' | 'FAX' | 'PAGER';
|
|
19
|
+
label?: string;
|
|
20
|
+
}>;
|
|
21
|
+
/** Email addresses */
|
|
22
|
+
emails?: Array<{
|
|
23
|
+
email: string;
|
|
24
|
+
type?: 'WORK' | 'HOME' | 'OTHER';
|
|
25
|
+
}>;
|
|
26
|
+
/** Website URLs */
|
|
27
|
+
urls?: Array<{
|
|
28
|
+
url: string;
|
|
29
|
+
type?: 'WORK' | 'HOME' | 'OTHER';
|
|
30
|
+
}>;
|
|
31
|
+
/** Physical addresses */
|
|
32
|
+
addresses?: Array<{
|
|
33
|
+
street?: string;
|
|
34
|
+
city?: string;
|
|
35
|
+
state?: string;
|
|
36
|
+
postalCode?: string;
|
|
37
|
+
country?: string;
|
|
38
|
+
type?: 'WORK' | 'HOME' | 'OTHER';
|
|
39
|
+
}>;
|
|
40
|
+
/** Birthday (YYYY-MM-DD format) */
|
|
41
|
+
birthday?: string;
|
|
42
|
+
/** Notes */
|
|
43
|
+
note?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Generate vCard string from contact data
|
|
47
|
+
*/
|
|
48
|
+
export declare const generateVCard: (contact: VCardContact) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Generate multiple vCards (for contact array)
|
|
51
|
+
*/
|
|
52
|
+
export declare const generateVCards: (contacts: VCardContact[]) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Parse vCard string to contact data (basic parser)
|
|
55
|
+
*/
|
|
56
|
+
export declare const parseVCard: (vcard: string) => Partial<VCardContact>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a simple contact card message content
|
|
59
|
+
*/
|
|
60
|
+
export declare const createContactCard: (contact: VCardContact) => {
|
|
61
|
+
contacts: {
|
|
62
|
+
displayName: string;
|
|
63
|
+
contacts: Array<{
|
|
64
|
+
vcard: string;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Create a contact array message content
|
|
70
|
+
*/
|
|
71
|
+
export declare const createContactCards: (contacts: VCardContact[]) => {
|
|
72
|
+
contacts: {
|
|
73
|
+
displayName: string;
|
|
74
|
+
contacts: Array<{
|
|
75
|
+
vcard: string;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Quick helper to create contact from phone number
|
|
81
|
+
*/
|
|
82
|
+
export declare const quickContact: (name: string, phone: string, options?: {
|
|
83
|
+
organization?: string;
|
|
84
|
+
email?: string;
|
|
85
|
+
}) => VCardContact;
|
|
86
|
+
//# sourceMappingURL=vcard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vcard.d.ts","sourceRoot":"","sources":["../../src/Utils/vcard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;IAC5B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;I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