MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / getStickerCommands

Function getStickerCommands

plugins/setcmd.js:25–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23const HAS_DB = !!(MONGO_URL || POSTGRES_URL || MYSQL_URL || SQLITE_URL);
24const STICKER_FILE = dataFile('sticker_commands.json');
25async function getStickerCommands() {
26 if (HAS_DB) {
27 const data = await store.getSetting('global', 'stickerCommands');
28 return data || {};
29 }
30 else {
31 try {
32 const dir = path.dirname(STICKER_FILE);
33 if (!fs.existsSync(dir)) {
34 fs.mkdirSync(dir, { recursive: true });
35 }
36 if (!fs.existsSync(STICKER_FILE)) {
37 fs.writeFileSync(STICKER_FILE, JSON.stringify({}));
38 return {};
39 }
40 return JSON.parse(fs.readFileSync(STICKER_FILE, 'utf8'));
41 }
42 catch {
43 return {};
44 }
45 }
46}
47async function saveStickerCommands(data) {
48 if (HAS_DB) {
49 await store.saveSetting('global', 'stickerCommands', data);

Callers 1

handlerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected