File size: 2,573 Bytes
a2b2aac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
import fetch from 'node-fetch'
import { Sticker } from 'wa-sticker-formatter'

export async function before(m, { match }) {
	let isCmd = (match[0] || '')[0], isChat = /net/.test(m.chat)
	/*
	if (/groupInvite/.test(m.mtype) && isChat) {
		let msg = m.message.groupInviteMessage
		await this.groupAcceptInviteV4(m.chat, msg)
	}
	*/
	/*
	if (/62895199754413/.test(this?.user?.jid)) {
		setInterval(async () => {
			
		}, 30 * 1000)
	}
	
	if (!isCmd && /image/.test(m.mtype) && isChat) {
		let sticker = await createSticker(await m.download())
		this.sendMessage(m.chat, { sticker }, { quoted: m })
	} else if (!isCmd && /video/.test(m.mtype) && isChat) {
		let sticker = await mp4ToWebp(await m.download())
		this.sendMessage(m.chat, { sticker }, { quoted: m })
	}
}

/* Function *//*
async function createSticker(img) {
	return (new Sticker(img, { type: 'full' })).toBuffer()
}

async function mp4ToWebp(file) {
	let getBase64 = file.toString('base64')
	const Format = {
		file: `data:video/mp4;base64,${getBase64}`,
		processOptions: {
			crop: false,
			startTime: '00:00:00.0',
			endTime: '00:00:06.0',
			loop: 0
		},
		stickerMetadata: {
			pack: '‎',
			author: '‎'
		},
		sessionInfo: {
			WA_VERSION: '2.2106.5',
			PAGE_UA: 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36',
			WA_AUTOMATE_VERSION: '3.6.10 UPDATE AVAILABLE: 3.6.11',
			BROWSER_VERSION: 'HeadlessChrome/88.0.4324.190',
			OS: 'Windows Server 2016',
			START_TS: 1614310326309,
			NUM: '6247',
			LAUNCH_TIME_MS: 7934,
			PHONE_VERSION: '2.20.205.16'
		},
		config: {
			sessionId: 'session',
			headless: true,
			qrTimeout: 20,
			authTimeout: 0,
			cacheEnabled: false,
			useChrome: true,
			killProcessOnBrowserClose: true,
			throwErrorOnTosBlock: false,
			chromiumArgs: [
				'--no-sandbox',
				'--disable-setuid-sandbox',
				'--aggressive-cache-discard',
				'--disable-cache',
				'--disable-application-cache',
				'--disable-offline-load-stale-cache',
				'--disk-cache-size=0'
			],
			executablePath: 'C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe',
			skipBrokenMethodsCheck: true,
			stickerServerEndpoint: true
		 }
	}
	let res = await fetch('https://sticker-api.openwa.dev/convertMp4BufferToWebpDataUrl', {
		method: 'post',
		headers: {
			Accept: 'application/json, text/plain, /',
			'Content-Type': 'application/json;charset=utf-8',
		},
		body: JSON.stringify(Format)
	})
	return Buffer.from((await res.text()).split(';base64,')[1], 'base64')
}
*/