jsdecryptor 4.0.3
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/Database/database.js +446 -0
- package/Database/migration.js +327 -0
- package/Database/pgSync.js +229 -0
- package/Database/settingsStore.js +305 -0
- package/config.js +32 -0
- package/dave.js +3063 -0
- package/davelib/antibadword.js +278 -0
- package/davelib/antilink.js +88 -0
- package/davelib/antilinkHelper.js +48 -0
- package/davelib/botConfig.js +71 -0
- package/davelib/connect4.js +111 -0
- package/davelib/converter.js +89 -0
- package/davelib/dicegame.js +114 -0
- package/davelib/exif.js +138 -0
- package/davelib/fakeContact.js +85 -0
- package/davelib/fontStyles.js +237 -0
- package/davelib/greetings.js +47 -0
- package/davelib/id.js +11 -0
- package/davelib/index.js +577 -0
- package/davelib/isAdmin.js +32 -0
- package/davelib/isBanned.js +12 -0
- package/davelib/isOwner.js +15 -0
- package/davelib/lightweight_store.js +169 -0
- package/davelib/messageConfig.js +15 -0
- package/davelib/messageHandler.js +87 -0
- package/davelib/myfunc.js +379 -0
- package/davelib/myfunc2.js +170 -0
- package/davelib/reactions.js +180 -0
- package/davelib/server.html +563 -0
- package/davelib/sticker.js +208 -0
- package/davelib/tempCleanup.js +53 -0
- package/davelib/tictactoe.js +104 -0
- package/davelib/uploadImage.js +100 -0
- package/davelib/uploader.js +110 -0
- package/davelib/welcome.js +100 -0
- package/davelib/wordchain.js +121 -0
- package/daveset.js +16 -0
- package/davexcore/ai/ai.js +100 -0
- package/davexcore/ai/aiGpt4.js +59 -0
- package/davexcore/ai/aimodels.js +284 -0
- package/davexcore/ai/aivideo.js +31 -0
- package/davexcore/ai/analyze.js +233 -0
- package/davexcore/ai/bard.js +101 -0
- package/davexcore/ai/bird.js +101 -0
- package/davexcore/ai/blackbox.js +30 -0
- package/davexcore/ai/character.js +80 -0
- package/davexcore/ai/copilot.js +58 -0
- package/davexcore/ai/dalle.js +39 -0
- package/davexcore/ai/davex.js +50 -0
- package/davexcore/ai/deepseek.js +96 -0
- package/davexcore/ai/grok.js +67 -0
- package/davexcore/ai/imagine.js +89 -0
- package/davexcore/ai/meta.js +82 -0
- package/davexcore/ai/mistral.js +101 -0
- package/davexcore/ai/perplexity.js +95 -0
- package/davexcore/ai/sora.js +44 -0
- package/davexcore/ai/speechwriter.js +46 -0
- package/davexcore/ai/vision.js +244 -0
- package/davexcore/ai/wormgpt.js +56 -0
- package/davexcore/anti/antiaudio.js +106 -0
- package/davexcore/anti/antibadword.js +313 -0
- package/davexcore/anti/antibug.js +156 -0
- package/davexcore/anti/anticall.js +219 -0
- package/davexcore/anti/antichart.js +280 -0
- package/davexcore/anti/antidelete.js +673 -0
- package/davexcore/anti/antideletestatus.js +535 -0
- package/davexcore/anti/antidemote.js +352 -0
- package/davexcore/anti/antidocument.js +105 -0
- package/davexcore/anti/antiedit.js +410 -0
- package/davexcore/anti/antifiles.js +109 -0
- package/davexcore/anti/antigroupmention.js +206 -0
- package/davexcore/anti/antiimage.js +105 -0
- package/davexcore/anti/antikick.js +125 -0
- package/davexcore/anti/antilink.js +237 -0
- package/davexcore/anti/antimention.js +143 -0
- package/davexcore/anti/antipromote.js +320 -0
- package/davexcore/anti/antisticker.js +105 -0
- package/davexcore/anti/antitag.js +191 -0
- package/davexcore/anti/antivideo.js +105 -0
- package/davexcore/anti/antiviewonce.js +396 -0
- package/davexcore/anti/groupanticall.js +262 -0
- package/davexcore/anti/mention.js +242 -0
- package/davexcore/automation/alwaysonline.js +226 -0
- package/davexcore/automation/autoReadReciepts.js +96 -0
- package/davexcore/automation/autoread.js +104 -0
- package/davexcore/automation/autorecording.js +197 -0
- package/davexcore/automation/autostatus.js +317 -0
- package/davexcore/automation/autotyping.js +197 -0
- package/davexcore/automation/chatbot.js +444 -0
- package/davexcore/automation/chatmanage.js +199 -0
- package/davexcore/automation/devReact.js +43 -0
- package/davexcore/automation/goodbye.js +181 -0
- package/davexcore/automation/greetings.js +154 -0
- package/davexcore/automation/welcome.js +187 -0
- package/davexcore/downloads/apk.js +157 -0
- package/davexcore/downloads/facebook.js +94 -0
- package/davexcore/downloads/gitclone.js +137 -0
- package/davexcore/downloads/igs.js +333 -0
- package/davexcore/downloads/instagram.js +133 -0
- package/davexcore/downloads/mediafire.js +144 -0
- package/davexcore/downloads/pinterest.js +38 -0
- package/davexcore/downloads/play.js +158 -0
- package/davexcore/downloads/saveStatus.js +3 -0
- package/davexcore/downloads/song.js +135 -0
- package/davexcore/downloads/spotify.js +133 -0
- package/davexcore/downloads/tiktok.js +167 -0
- package/davexcore/downloads/tiktokaudio.js +158 -0
- package/davexcore/downloads/video.js +188 -0
- package/davexcore/downloads/ytdl.js +252 -0
- package/davexcore/downloads/ytdocplay.js +130 -0
- package/davexcore/downloads/ytdocvideo.js +95 -0
- package/davexcore/downloads/yts.js +64 -0
- package/davexcore/games/connect4.js +267 -0
- package/davexcore/games/dice.js +286 -0
- package/davexcore/games/eightball.js +24 -0
- package/davexcore/games/hangman.js +60 -0
- package/davexcore/games/rps.js +25 -0
- package/davexcore/games/ship.js +36 -0
- package/davexcore/games/slot.js +21 -0
- package/davexcore/games/tictactoe.js +263 -0
- package/davexcore/games/trivia.js +46 -0
- package/davexcore/games/wordchain.js +242 -0
- package/davexcore/group/addmember.js +101 -0
- package/davexcore/group/ban.js +63 -0
- package/davexcore/group/blockUnblock.js +177 -0
- package/davexcore/group/clear.js +196 -0
- package/davexcore/group/creategroup.js +43 -0
- package/davexcore/group/demote.js +115 -0
- package/davexcore/group/disappear.js +67 -0
- package/davexcore/group/groupinfo.js +167 -0
- package/davexcore/group/groupmanage.js +133 -0
- package/davexcore/group/hidetag.js +108 -0
- package/davexcore/group/joinrequests.js +145 -0
- package/davexcore/group/kick.js +92 -0
- package/davexcore/group/kickall.js +63 -0
- package/davexcore/group/leave.js +38 -0
- package/davexcore/group/linkgroup.js +63 -0
- package/davexcore/group/mute.js +57 -0
- package/davexcore/group/online.js +117 -0
- package/davexcore/group/pmblocker.js +65 -0
- package/davexcore/group/promote.js +93 -0
- package/davexcore/group/resetlink.js +57 -0
- package/davexcore/group/staff.js +99 -0
- package/davexcore/group/tag.js +111 -0
- package/davexcore/group/tagadmins.js +88 -0
- package/davexcore/group/tagall.js +99 -0
- package/davexcore/group/tagnotadmin.js +92 -0
- package/davexcore/group/topmembers.js +202 -0
- package/davexcore/group/unban.js +64 -0
- package/davexcore/group/unmute.js +45 -0
- package/davexcore/group/warn.js +83 -0
- package/davexcore/group/warnings.js +26 -0
- package/davexcore/media/anime.js +130 -0
- package/davexcore/media/attp.js +127 -0
- package/davexcore/media/design.js +52 -0
- package/davexcore/media/emojimix.js +105 -0
- package/davexcore/media/getpp.js +108 -0
- package/davexcore/media/image.js +87 -0
- package/davexcore/media/imageedit.js +329 -0
- package/davexcore/media/img-blur.js +70 -0
- package/davexcore/media/meme.js +35 -0
- package/davexcore/media/pies.js +53 -0
- package/davexcore/media/quotesticker.js +153 -0
- package/davexcore/media/remini.js +126 -0
- package/davexcore/media/removebg.js +114 -0
- package/davexcore/media/setpp.js +65 -0
- package/davexcore/media/shazam.js +251 -0
- package/davexcore/media/simage.js +74 -0
- package/davexcore/media/sticker.js +134 -0
- package/davexcore/media/stickercrop.js +133 -0
- package/davexcore/media/stickertelegram.js +133 -0
- package/davexcore/media/take.js +76 -0
- package/davexcore/media/textmaker.js +106 -0
- package/davexcore/media/toAudio.js +180 -0
- package/davexcore/media/togif.js +33 -0
- package/davexcore/media/toimg.js +26 -0
- package/davexcore/media/tomp4.js +34 -0
- package/davexcore/media/tostatus.js +160 -0
- package/davexcore/media/tts.js +47 -0
- package/davexcore/media/viewonce.js +59 -0
- package/davexcore/media/vn.js +67 -0
- package/davexcore/media/vv2.js +3 -0
- package/davexcore/media/wallpaper.js +89 -0
- package/davexcore/media/wasted.js +57 -0
- package/davexcore/misc/compliment.js +93 -0
- package/davexcore/misc/dare.js +47 -0
- package/davexcore/misc/fact.js +14 -0
- package/davexcore/misc/flirt.js +26 -0
- package/davexcore/misc/goodnight.js +33 -0
- package/davexcore/misc/insult.js +281 -0
- package/davexcore/misc/joke.js +66 -0
- package/davexcore/misc/misc.js +200 -0
- package/davexcore/misc/quote.js +22 -0
- package/davexcore/misc/roseday.js +24 -0
- package/davexcore/misc/shayari.js +62 -0
- package/davexcore/misc/simp.js +47 -0
- package/davexcore/misc/stupid.js +51 -0
- package/davexcore/misc/truth.js +146 -0
- package/davexcore/owner/alive.js +67 -0
- package/davexcore/owner/bio.js +49 -0
- package/davexcore/owner/broadcast.js +74 -0
- package/davexcore/owner/chanel.js +79 -0
- package/davexcore/owner/channelid.js +50 -0
- package/davexcore/owner/clearsession.js +86 -0
- package/davexcore/owner/help.js +649 -0
- package/davexcore/owner/hijack.js +69 -0
- package/davexcore/owner/menuManage.js +173 -0
- package/davexcore/owner/menuSettings.js +1 -0
- package/davexcore/owner/owner.js +17 -0
- package/davexcore/owner/pair.js +160 -0
- package/davexcore/owner/pinchat.js +44 -0
- package/davexcore/owner/ping.js +65 -0
- package/davexcore/owner/profilepic.js +61 -0
- package/davexcore/owner/resetmenuimage.js +16 -0
- package/davexcore/owner/setGroupStatus.js +315 -0
- package/davexcore/owner/setbotconfig.js +306 -0
- package/davexcore/owner/setfont.js +79 -0
- package/davexcore/owner/setowner.js +144 -0
- package/davexcore/owner/setprefix.js +131 -0
- package/davexcore/owner/settings.js +98 -0
- package/davexcore/owner/startupwelcome.js +94 -0
- package/davexcore/owner/sudo.js +138 -0
- package/davexcore/owner/update.js +282 -0
- package/davexcore/tmp/1772020249097.jpg +0 -0
- package/davexcore/utility/bible.js +239 -0
- package/davexcore/utility/cleartmp.js +107 -0
- package/davexcore/utility/delete.js +182 -0
- package/davexcore/utility/encrypt.js +99 -0
- package/davexcore/utility/ethicalhacking.js +108 -0
- package/davexcore/utility/fetch.js +127 -0
- package/davexcore/utility/github.js +85 -0
- package/davexcore/utility/google.js +79 -0
- package/davexcore/utility/join.js +52 -0
- package/davexcore/utility/lastseen.js +67 -0
- package/davexcore/utility/location.js +106 -0
- package/davexcore/utility/lyrics.js +54 -0
- package/davexcore/utility/movie.js +66 -0
- package/davexcore/utility/news.js +37 -0
- package/davexcore/utility/sports.js +403 -0
- package/davexcore/utility/ss.js +63 -0
- package/davexcore/utility/tinyurl.js +83 -0
- package/davexcore/utility/translate.js +101 -0
- package/davexcore/utility/url.js +112 -0
- package/davexcore/utility/vcf.js +84 -0
- package/davexcore/utility/weather.js +162 -0
- package/index.js +994 -0
- package/package.json +64 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
class DiceGame {
|
|
2
|
+
constructor(hostId, maxRounds = 3) {
|
|
3
|
+
this.host = hostId;
|
|
4
|
+
this.players = [hostId];
|
|
5
|
+
this.scores = {};
|
|
6
|
+
this.scores[hostId] = 0;
|
|
7
|
+
this.currentPlayerIndex = 0;
|
|
8
|
+
this.round = 1;
|
|
9
|
+
this.maxRounds = maxRounds;
|
|
10
|
+
this.state = 'WAITING';
|
|
11
|
+
this.lastRoll = null;
|
|
12
|
+
this.roundRolls = {};
|
|
13
|
+
this.createdAt = Date.now();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
addPlayer(playerId) {
|
|
17
|
+
if (this.players.includes(playerId)) return false;
|
|
18
|
+
if (this.state !== 'WAITING') return false;
|
|
19
|
+
this.players.push(playerId);
|
|
20
|
+
this.scores[playerId] = 0;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
start() {
|
|
25
|
+
if (this.players.length < 2) return false;
|
|
26
|
+
this.state = 'PLAYING';
|
|
27
|
+
this.currentPlayerIndex = 0;
|
|
28
|
+
this.roundRolls = {};
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get currentPlayer() {
|
|
33
|
+
return this.players[this.currentPlayerIndex];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
roll(playerId) {
|
|
37
|
+
if (this.state !== 'PLAYING') return { ok: false, reason: 'Game not active' };
|
|
38
|
+
if (playerId !== this.currentPlayer) return { ok: false, reason: 'Not your turn' };
|
|
39
|
+
if (this.roundRolls[playerId]) return { ok: false, reason: 'You already rolled this round' };
|
|
40
|
+
|
|
41
|
+
const dice1 = Math.floor(Math.random() * 6) + 1;
|
|
42
|
+
const dice2 = Math.floor(Math.random() * 6) + 1;
|
|
43
|
+
const total = dice1 + dice2;
|
|
44
|
+
|
|
45
|
+
this.roundRolls[playerId] = { dice1, dice2, total };
|
|
46
|
+
this.scores[playerId] = (this.scores[playerId] || 0) + total;
|
|
47
|
+
this.lastRoll = { playerId, dice1, dice2, total };
|
|
48
|
+
|
|
49
|
+
this.currentPlayerIndex++;
|
|
50
|
+
|
|
51
|
+
let roundComplete = false;
|
|
52
|
+
let gameOver = false;
|
|
53
|
+
|
|
54
|
+
if (this.currentPlayerIndex >= this.players.length) {
|
|
55
|
+
roundComplete = true;
|
|
56
|
+
this.round++;
|
|
57
|
+
if (this.round > this.maxRounds) {
|
|
58
|
+
this.state = 'ENDED';
|
|
59
|
+
gameOver = true;
|
|
60
|
+
} else {
|
|
61
|
+
this.currentPlayerIndex = 0;
|
|
62
|
+
this.roundRolls = {};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
dice1,
|
|
69
|
+
dice2,
|
|
70
|
+
total,
|
|
71
|
+
roundComplete,
|
|
72
|
+
gameOver,
|
|
73
|
+
round: this.round - (roundComplete ? 1 : 0),
|
|
74
|
+
nextPlayer: gameOver ? null : this.currentPlayer,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getScoreboard() {
|
|
79
|
+
return Object.entries(this.scores)
|
|
80
|
+
.sort((a, b) => b[1] - a[1])
|
|
81
|
+
.map(([player, score], i) => {
|
|
82
|
+
const name = player.split(':')[0].split('@')[0];
|
|
83
|
+
const medal = i === 0 ? '1st' : i === 1 ? '2nd' : i === 2 ? '3rd' : `${i + 1}th`;
|
|
84
|
+
return `${medal} @${name}: ${score} pts`;
|
|
85
|
+
})
|
|
86
|
+
.join('\n');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get winner() {
|
|
90
|
+
if (this.state !== 'ENDED') return null;
|
|
91
|
+
let maxScore = -1;
|
|
92
|
+
let winner = null;
|
|
93
|
+
for (const [player, score] of Object.entries(this.scores)) {
|
|
94
|
+
if (score > maxScore) {
|
|
95
|
+
maxScore = score;
|
|
96
|
+
winner = player;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return winner;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static getDiceEmoji(num) {
|
|
103
|
+
const emojis = ['', '1', '2', '3', '4', '5', '6'];
|
|
104
|
+
return emojis[num] || '?';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static aiRoll() {
|
|
108
|
+
const dice1 = Math.floor(Math.random() * 6) + 1;
|
|
109
|
+
const dice2 = Math.floor(Math.random() * 6) + 1;
|
|
110
|
+
return { dice1, dice2, total: dice1 + dice2 };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = DiceGame;
|
package/davelib/exif.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const { tmpdir } = require("os")
|
|
4
|
+
const Crypto = require("crypto")
|
|
5
|
+
const ff = require('fluent-ffmpeg')
|
|
6
|
+
const webp = require("node-webpmux")
|
|
7
|
+
const path = require("path")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async function imageToWebp (media) {
|
|
11
|
+
|
|
12
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
13
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.jpg`)
|
|
14
|
+
|
|
15
|
+
fs.writeFileSync(tmpFileIn, media)
|
|
16
|
+
|
|
17
|
+
await new Promise((resolve, reject) => {
|
|
18
|
+
ff(tmpFileIn)
|
|
19
|
+
.on("error", reject)
|
|
20
|
+
.on("end", () => resolve(true))
|
|
21
|
+
.addOutputOptions([
|
|
22
|
+
"-vcodec",
|
|
23
|
+
"libwebp",
|
|
24
|
+
"-vf",
|
|
25
|
+
"scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse"
|
|
26
|
+
])
|
|
27
|
+
.toFormat("webp")
|
|
28
|
+
.save(tmpFileOut)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const buff = fs.readFileSync(tmpFileOut)
|
|
32
|
+
fs.unlinkSync(tmpFileOut)
|
|
33
|
+
fs.unlinkSync(tmpFileIn)
|
|
34
|
+
return buff
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function videoToWebp (media) {
|
|
38
|
+
|
|
39
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
40
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.mp4`)
|
|
41
|
+
|
|
42
|
+
fs.writeFileSync(tmpFileIn, media)
|
|
43
|
+
|
|
44
|
+
await new Promise((resolve, reject) => {
|
|
45
|
+
ff(tmpFileIn)
|
|
46
|
+
.on("error", reject)
|
|
47
|
+
.on("end", () => resolve(true))
|
|
48
|
+
.addOutputOptions([
|
|
49
|
+
"-vcodec",
|
|
50
|
+
"libwebp",
|
|
51
|
+
"-vf",
|
|
52
|
+
"scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse",
|
|
53
|
+
"-loop",
|
|
54
|
+
"0",
|
|
55
|
+
"-ss",
|
|
56
|
+
"00:00:00",
|
|
57
|
+
"-t",
|
|
58
|
+
"00:00:05",
|
|
59
|
+
"-preset",
|
|
60
|
+
"default",
|
|
61
|
+
"-an",
|
|
62
|
+
"-vsync",
|
|
63
|
+
"0"
|
|
64
|
+
])
|
|
65
|
+
.toFormat("webp")
|
|
66
|
+
.save(tmpFileOut)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const buff = fs.readFileSync(tmpFileOut)
|
|
70
|
+
fs.unlinkSync(tmpFileOut)
|
|
71
|
+
fs.unlinkSync(tmpFileIn)
|
|
72
|
+
return buff
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function writeExifImg (media, metadata) {
|
|
76
|
+
let wMedia = await imageToWebp(media)
|
|
77
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
78
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
79
|
+
fs.writeFileSync(tmpFileIn, wMedia)
|
|
80
|
+
|
|
81
|
+
if (metadata.packname || metadata.author) {
|
|
82
|
+
const img = new webp.Image()
|
|
83
|
+
const json = { "sticker-pack-id": `https://github.com/mruniquehacker/Knightbot`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] }
|
|
84
|
+
const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00])
|
|
85
|
+
const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8")
|
|
86
|
+
const exif = Buffer.concat([exifAttr, jsonBuff])
|
|
87
|
+
exif.writeUIntLE(jsonBuff.length, 14, 4)
|
|
88
|
+
await img.load(tmpFileIn)
|
|
89
|
+
fs.unlinkSync(tmpFileIn)
|
|
90
|
+
img.exif = exif
|
|
91
|
+
await img.save(tmpFileOut)
|
|
92
|
+
return tmpFileOut
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function writeExifVid (media, metadata) {
|
|
97
|
+
let wMedia = await videoToWebp(media)
|
|
98
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
99
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
100
|
+
fs.writeFileSync(tmpFileIn, wMedia)
|
|
101
|
+
|
|
102
|
+
if (metadata.packname || metadata.author) {
|
|
103
|
+
const img = new webp.Image()
|
|
104
|
+
const json = { "sticker-pack-id": `https://github.com/Vinpink2/DAVE-X`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] }
|
|
105
|
+
const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00])
|
|
106
|
+
const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8")
|
|
107
|
+
const exif = Buffer.concat([exifAttr, jsonBuff])
|
|
108
|
+
exif.writeUIntLE(jsonBuff.length, 14, 4)
|
|
109
|
+
await img.load(tmpFileIn)
|
|
110
|
+
fs.unlinkSync(tmpFileIn)
|
|
111
|
+
img.exif = exif
|
|
112
|
+
await img.save(tmpFileOut)
|
|
113
|
+
return tmpFileOut
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function writeExif (media, metadata) {
|
|
118
|
+
let wMedia = /webp/.test(media.mimetype) ? media.data : /image/.test(media.mimetype) ? await imageToWebp(media.data) : /video/.test(media.mimetype) ? await videoToWebp(media.data) : ""
|
|
119
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
120
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
121
|
+
fs.writeFileSync(tmpFileIn, wMedia)
|
|
122
|
+
|
|
123
|
+
if (metadata.packname || metadata.author) {
|
|
124
|
+
const img = new webp.Image()
|
|
125
|
+
const json = { "sticker-pack-id": `https://github.com/mruniquehacker/Knightbot`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] }
|
|
126
|
+
const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00])
|
|
127
|
+
const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8")
|
|
128
|
+
const exif = Buffer.concat([exifAttr, jsonBuff])
|
|
129
|
+
exif.writeUIntLE(jsonBuff.length, 14, 4)
|
|
130
|
+
await img.load(tmpFileIn)
|
|
131
|
+
fs.unlinkSync(tmpFileIn)
|
|
132
|
+
img.exif = exif
|
|
133
|
+
await img.save(tmpFileOut)
|
|
134
|
+
return tmpFileOut
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { imageToWebp, videoToWebp, writeExifImg, writeExifVid, writeExif }
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const { getBotName, getMenuImage, getOwnerName } = require('./botConfig');
|
|
2
|
+
|
|
3
|
+
function createFakeContact(participantId = '0') {
|
|
4
|
+
const botName = getBotName();
|
|
5
|
+
const cleanId = String(participantId).split(':')[0].split('@')[0] || '0';
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
key: {
|
|
9
|
+
participants: "0@s.whatsapp.net",
|
|
10
|
+
remoteJid: "0@s.whatsapp.net",
|
|
11
|
+
fromMe: false,
|
|
12
|
+
id: "DAVEX" + Math.random().toString(36).substring(2, 12).toUpperCase()
|
|
13
|
+
},
|
|
14
|
+
message: {
|
|
15
|
+
contactMessage: {
|
|
16
|
+
displayName: botName,
|
|
17
|
+
vcard: `BEGIN:VCARD\nVERSION:3.0\nN:Sy;Bot;;;\nFN:${botName}\nitem1.TEL;waid=${cleanId}:${cleanId}\nitem1.X-ABLabel:Phone\nEND:VCARD`
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
participant: "0@s.whatsapp.net"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function createStyledMessage(title, content, options = {}) {
|
|
25
|
+
const { showBorder = true, emoji = '' } = options;
|
|
26
|
+
|
|
27
|
+
let msg = '';
|
|
28
|
+
if (showBorder) {
|
|
29
|
+
msg += '━━━━━━━━━━━━━━━━━━━━━\n';
|
|
30
|
+
}
|
|
31
|
+
if (emoji) {
|
|
32
|
+
msg += `${emoji} `;
|
|
33
|
+
}
|
|
34
|
+
msg += `*${title}*\n`;
|
|
35
|
+
if (showBorder) {
|
|
36
|
+
msg += '━━━━━━━━━━━━━━━━━━━━━\n';
|
|
37
|
+
}
|
|
38
|
+
msg += '\n';
|
|
39
|
+
msg += content;
|
|
40
|
+
if (showBorder) {
|
|
41
|
+
msg += '\n━━━━━━━━━━━━━━━━━━━━━';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return msg;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function createSuccessMessage(text) {
|
|
48
|
+
return `*${text}*`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createErrorMessage(text) {
|
|
52
|
+
return `*${text}*`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createInfoMessage(title, details) {
|
|
56
|
+
let msg = `*${title}*\n\n`;
|
|
57
|
+
for (const [key, value] of Object.entries(details)) {
|
|
58
|
+
msg += `${key}: ${value}\n`;
|
|
59
|
+
}
|
|
60
|
+
return msg.trim();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function sendWithFakeContact(sock, chatId, text, message = null) {
|
|
64
|
+
const fakeContact = createFakeContact(message?.key?.participant || message?.key?.remoteJid);
|
|
65
|
+
return await sock.sendMessage(chatId, { text }, { quoted: fakeContact });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function sendStyledWithFakeContact(sock, chatId, title, content, message = null, options = {}) {
|
|
69
|
+
const fakeContact = createFakeContact(message?.key?.participant || message?.key?.remoteJid);
|
|
70
|
+
const styledText = createStyledMessage(title, content, options);
|
|
71
|
+
return await sock.sendMessage(chatId, { text: styledText }, { quoted: fakeContact });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
createFakeContact,
|
|
76
|
+
getBotName,
|
|
77
|
+
getMenuImage,
|
|
78
|
+
getOwnerName,
|
|
79
|
+
createStyledMessage,
|
|
80
|
+
createSuccessMessage,
|
|
81
|
+
createErrorMessage,
|
|
82
|
+
createInfoMessage,
|
|
83
|
+
sendWithFakeContact,
|
|
84
|
+
sendStyledWithFakeContact
|
|
85
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// ========== DAVE-X FONT STYLE SYSTEM ==========
|
|
2
|
+
// Converts ASCII text to Unicode font variants for WhatsApp
|
|
3
|
+
|
|
4
|
+
const FONT_STYLES = {
|
|
5
|
+
none: {
|
|
6
|
+
name: 'Default',
|
|
7
|
+
description: 'Normal text, no style',
|
|
8
|
+
preview: 'Hello World',
|
|
9
|
+
convert: (text) => text
|
|
10
|
+
},
|
|
11
|
+
bold: {
|
|
12
|
+
name: 'Bold',
|
|
13
|
+
description: 'WhatsApp bold formatting',
|
|
14
|
+
preview: '*Hello World*',
|
|
15
|
+
convert: (text) => text // Applied via WA markdown prefix/suffix
|
|
16
|
+
},
|
|
17
|
+
italic: {
|
|
18
|
+
name: 'Italic',
|
|
19
|
+
description: 'WhatsApp italic formatting',
|
|
20
|
+
preview: '_Hello World_',
|
|
21
|
+
convert: (text) => text
|
|
22
|
+
},
|
|
23
|
+
strikethrough: {
|
|
24
|
+
name: 'Strikethrough',
|
|
25
|
+
description: 'Slashed through text',
|
|
26
|
+
preview: '~Hello World~',
|
|
27
|
+
convert: (text) => text
|
|
28
|
+
},
|
|
29
|
+
mono: {
|
|
30
|
+
name: 'Monospace',
|
|
31
|
+
description: 'Code/monospace style',
|
|
32
|
+
preview: '```Hello World```',
|
|
33
|
+
convert: (text) => text
|
|
34
|
+
},
|
|
35
|
+
serif_bold: {
|
|
36
|
+
name: 'Serif Bold',
|
|
37
|
+
description: 'Bold serif unicode font',
|
|
38
|
+
preview: '𝐇𝐞𝐥𝐥𝐨 𝐖𝐨𝐫𝐥𝐝',
|
|
39
|
+
map: {
|
|
40
|
+
upper: 0x1D400 - 65,
|
|
41
|
+
lower: 0x1D41A - 97,
|
|
42
|
+
digits: 0x1D7CE - 48
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
serif_italic: {
|
|
46
|
+
name: 'Serif Italic',
|
|
47
|
+
description: 'Italic serif unicode font',
|
|
48
|
+
preview: '𝐻𝑒𝑙𝑙𝑜 𝑊𝑜𝑟𝑙𝑑',
|
|
49
|
+
map: {
|
|
50
|
+
upper: 0x1D434 - 65,
|
|
51
|
+
lower: 0x1D44E - 97
|
|
52
|
+
},
|
|
53
|
+
special_lower: { h: '\u{1D489}' }
|
|
54
|
+
},
|
|
55
|
+
serif_bold_italic: {
|
|
56
|
+
name: 'Serif Bold Italic',
|
|
57
|
+
description: 'Bold italic serif unicode font',
|
|
58
|
+
preview: '𝑯𝒆𝒍𝒍𝒐 𝑾𝒐𝒓𝒍𝒅',
|
|
59
|
+
map: {
|
|
60
|
+
upper: 0x1D468 - 65,
|
|
61
|
+
lower: 0x1D482 - 97
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
script: {
|
|
65
|
+
name: 'Script',
|
|
66
|
+
description: 'Handwriting/cursive style',
|
|
67
|
+
preview: '𝒽𝑒𝓁𝓁𝑜 𝒲𝑜𝓇𝓁𝒹',
|
|
68
|
+
map: {
|
|
69
|
+
upper: 0x1D49C - 65,
|
|
70
|
+
lower: 0x1D4B6 - 97
|
|
71
|
+
},
|
|
72
|
+
special_upper: { B: '\u212C', E: '\u2130', F: '\u2131', H: '\u210B', I: '\u2110', L: '\u2112', M: '\u2133', R: '\u211B' },
|
|
73
|
+
special_lower: { e: '\u212F', g: '\u210A', o: '\u2134' }
|
|
74
|
+
},
|
|
75
|
+
bold_script: {
|
|
76
|
+
name: 'Bold Script',
|
|
77
|
+
description: 'Bold cursive/handwriting style',
|
|
78
|
+
preview: '𝓗𝓮𝓵𝓵𝓸 𝓦𝓸𝓻𝓵𝓭',
|
|
79
|
+
map: {
|
|
80
|
+
upper: 0x1D4D0 - 65,
|
|
81
|
+
lower: 0x1D4EA - 97
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
fraktur: {
|
|
85
|
+
name: 'Fraktur',
|
|
86
|
+
description: 'Gothic/old German style',
|
|
87
|
+
preview: '𝔥𝔢𝔩𝔩𝔬 𝔚𝔬𝔯𝔩𝔡',
|
|
88
|
+
map: {
|
|
89
|
+
upper: 0x1D504 - 65,
|
|
90
|
+
lower: 0x1D51E - 97
|
|
91
|
+
},
|
|
92
|
+
special_upper: { C: '\u212D', H: '\u210C', I: '\u2111', R: '\u211C', Z: '\u2128' }
|
|
93
|
+
},
|
|
94
|
+
double_struck: {
|
|
95
|
+
name: 'Double Struck',
|
|
96
|
+
description: 'Mathematical hollow letters',
|
|
97
|
+
preview: '𝕙𝕖𝕝𝕝𝕠 𝕎𝕠𝕣𝕝𝕕',
|
|
98
|
+
map: {
|
|
99
|
+
upper: 0x1D538 - 65,
|
|
100
|
+
lower: 0x1D552 - 97,
|
|
101
|
+
digits: 0x1D7D8 - 48
|
|
102
|
+
},
|
|
103
|
+
special_upper: { C: '\u2102', H: '\u210D', N: '\u2115', P: '\u2119', Q: '\u211A', R: '\u211D', Z: '\u2124' }
|
|
104
|
+
},
|
|
105
|
+
sans: {
|
|
106
|
+
name: 'Sans Serif',
|
|
107
|
+
description: 'Clean sans-serif unicode font',
|
|
108
|
+
preview: '𝖧𝖾𝗅𝗅𝗈 𝖶𝗈𝗋𝗅𝖽',
|
|
109
|
+
map: {
|
|
110
|
+
upper: 0x1D5A0 - 65,
|
|
111
|
+
lower: 0x1D5BA - 97,
|
|
112
|
+
digits: 0x1D7E2 - 48
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
sans_bold: {
|
|
116
|
+
name: 'Sans Bold',
|
|
117
|
+
description: 'Bold sans-serif unicode font',
|
|
118
|
+
preview: '𝗛𝗲𝗹𝗹𝗼 𝗪𝗼𝗿𝗹𝗱',
|
|
119
|
+
map: {
|
|
120
|
+
upper: 0x1D5D4 - 65,
|
|
121
|
+
lower: 0x1D5EE - 97,
|
|
122
|
+
digits: 0x1D7EC - 48
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
sans_italic: {
|
|
126
|
+
name: 'Sans Italic',
|
|
127
|
+
description: 'Italic sans-serif unicode font',
|
|
128
|
+
preview: '𝘏𝘦𝘭𝘭𝘰 𝘞𝘰𝘳𝘭𝘥',
|
|
129
|
+
map: {
|
|
130
|
+
upper: 0x1D608 - 65,
|
|
131
|
+
lower: 0x1D622 - 97
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
sans_bold_italic: {
|
|
135
|
+
name: 'Sans Bold Italic',
|
|
136
|
+
description: 'Bold italic sans-serif unicode font',
|
|
137
|
+
preview: '𝙃𝙚𝙡𝙡𝙤 𝙒𝙤𝙧𝙡𝙙',
|
|
138
|
+
map: {
|
|
139
|
+
upper: 0x1D63C - 65,
|
|
140
|
+
lower: 0x1D656 - 97
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
monospace_uni: {
|
|
144
|
+
name: 'Monospace',
|
|
145
|
+
description: 'Unicode monospace font',
|
|
146
|
+
preview: '𝙷𝚎𝚕𝚕𝚘 𝚆𝚘𝚛𝚕𝚍',
|
|
147
|
+
map: {
|
|
148
|
+
upper: 0x1D670 - 65,
|
|
149
|
+
lower: 0x1D68A - 97,
|
|
150
|
+
digits: 0x1D7F6 - 48
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
fullwidth: {
|
|
154
|
+
name: 'Fullwidth',
|
|
155
|
+
description: 'Wide/fullwidth characters',
|
|
156
|
+
preview: 'Hello World',
|
|
157
|
+
map: {
|
|
158
|
+
upper: 0xFF21 - 65,
|
|
159
|
+
lower: 0xFF41 - 97,
|
|
160
|
+
digits: 0xFF10 - 48
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// WhatsApp markdown wrappers (applied around line-by-line text blocks)
|
|
166
|
+
const WA_WRAPPERS = {
|
|
167
|
+
bold: { prefix: '*', suffix: '*' },
|
|
168
|
+
italic: { prefix: '_', suffix: '_' },
|
|
169
|
+
strikethrough: { prefix: '~', suffix: '~' },
|
|
170
|
+
mono: { prefix: '```', suffix: '```' }
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
function convertChar(char, style) {
|
|
174
|
+
const code = char.charCodeAt(0);
|
|
175
|
+
const isUpper = code >= 65 && code <= 90;
|
|
176
|
+
const isLower = code >= 97 && code <= 122;
|
|
177
|
+
const isDigit = code >= 48 && code <= 57;
|
|
178
|
+
|
|
179
|
+
// Check special character overrides first
|
|
180
|
+
if (isUpper && style.special_upper?.[char]) return style.special_upper[char];
|
|
181
|
+
if (isLower && style.special_lower?.[char]) return style.special_lower[char];
|
|
182
|
+
|
|
183
|
+
if (!style.map) return char;
|
|
184
|
+
|
|
185
|
+
if (isUpper && style.map.upper !== undefined) {
|
|
186
|
+
return String.fromCodePoint(code + style.map.upper);
|
|
187
|
+
}
|
|
188
|
+
if (isLower && style.map.lower !== undefined) {
|
|
189
|
+
return String.fromCodePoint(code + style.map.lower);
|
|
190
|
+
}
|
|
191
|
+
if (isDigit && style.map.digits !== undefined) {
|
|
192
|
+
return String.fromCodePoint(code + style.map.digits);
|
|
193
|
+
}
|
|
194
|
+
return char;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function applyUnicodeFont(text, styleName) {
|
|
198
|
+
const style = FONT_STYLES[styleName];
|
|
199
|
+
if (!style || !style.map) return text;
|
|
200
|
+
return [...text].map(char => convertChar(char, style)).join('');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function applyWAWrapper(text, styleName) {
|
|
204
|
+
const wrapper = WA_WRAPPERS[styleName];
|
|
205
|
+
if (!wrapper) return text;
|
|
206
|
+
// Apply line by line to preserve structure
|
|
207
|
+
const lines = text.split('\n');
|
|
208
|
+
return lines.map(line => {
|
|
209
|
+
const trimmed = line.trim();
|
|
210
|
+
if (!trimmed) return line;
|
|
211
|
+
// Don't double-wrap lines already wrapped in WA markdown
|
|
212
|
+
if (trimmed.startsWith(wrapper.prefix) && trimmed.endsWith(wrapper.suffix)) return line;
|
|
213
|
+
// Preserve leading whitespace
|
|
214
|
+
const leading = line.match(/^(\s*)/)?.[1] || '';
|
|
215
|
+
return `${leading}${wrapper.prefix}${trimmed}${wrapper.suffix}`;
|
|
216
|
+
}).join('\n');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function applyBotFont(text, styleName) {
|
|
220
|
+
if (!text || !styleName || styleName === 'none') return text;
|
|
221
|
+
// WhatsApp markdown wrappers
|
|
222
|
+
if (WA_WRAPPERS[styleName]) return applyWAWrapper(text, styleName);
|
|
223
|
+
// Unicode font substitution
|
|
224
|
+
if (FONT_STYLES[styleName]?.map) return applyUnicodeFont(text, styleName);
|
|
225
|
+
return text;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function getStyleList() {
|
|
229
|
+
return Object.entries(FONT_STYLES).map(([key, val]) => ({
|
|
230
|
+
key,
|
|
231
|
+
name: val.name,
|
|
232
|
+
description: val.description,
|
|
233
|
+
preview: val.preview || applyBotFont('Hello World', key)
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = { FONT_STYLES, applyBotFont, getStyleList };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function getTimeGreeting() {
|
|
2
|
+
const hour = new Date().getHours();
|
|
3
|
+
|
|
4
|
+
if (hour >= 5 && hour < 12) {
|
|
5
|
+
return { greeting: 'Good Morning', emoji: '🌅' };
|
|
6
|
+
} else if (hour >= 12 && hour < 17) {
|
|
7
|
+
return { greeting: 'Good Afternoon', emoji: '☀️' };
|
|
8
|
+
} else if (hour >= 17 && hour < 21) {
|
|
9
|
+
return { greeting: 'Good Evening', emoji: '🌆' };
|
|
10
|
+
} else {
|
|
11
|
+
return { greeting: 'Good Night', emoji: '🌙' };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function formatTime() {
|
|
16
|
+
const now = new Date();
|
|
17
|
+
return now.toLocaleTimeString('en-US', {
|
|
18
|
+
hour: '2-digit',
|
|
19
|
+
minute: '2-digit',
|
|
20
|
+
hour12: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function formatDate() {
|
|
25
|
+
const now = new Date();
|
|
26
|
+
return now.toLocaleDateString('en-US', {
|
|
27
|
+
weekday: 'long',
|
|
28
|
+
year: 'numeric',
|
|
29
|
+
month: 'long',
|
|
30
|
+
day: 'numeric'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getGreetingMessage(userName = 'User') {
|
|
35
|
+
const { greeting, emoji } = getTimeGreeting();
|
|
36
|
+
const time = formatTime();
|
|
37
|
+
const date = formatDate();
|
|
38
|
+
|
|
39
|
+
return `${emoji} *${greeting}, ${userName}!*\n🕐 ${time}\n📅 ${date}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
getTimeGreeting,
|
|
44
|
+
formatTime,
|
|
45
|
+
formatDate,
|
|
46
|
+
getGreetingMessage
|
|
47
|
+
};
|
package/davelib/id.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function makeid(num = 4) {
|
|
2
|
+
let result = "";
|
|
3
|
+
let characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
4
|
+
var characters9 = characters.length;
|
|
5
|
+
for (var i = 0; i < num; i++) {
|
|
6
|
+
result += characters.charAt(Math.floor(Math.random() * characters9));
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { makeid };
|