MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handler

Function handler

plugins/tinytext.ts:25–60  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

23 usage: '.smallcaps <text> OR reply to a message',
24
25 async handler(sock: any, message: any, args: any, context: BotContext) {
26 const chatId = context.chatId || message.key.remoteJid;
27
28 try {
29 let txt = args?.join(' ') || "";
30 const quoted = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
31 if (quoted) {
32 txt = quoted.conversation || quoted.extendedTextMessage?.text || quoted.imageMessage?.caption || txt;
33 }
34
35 txt = txt.replace(/^\.\w+\s*/, '').trim();
36
37 if (!txt) {
38 return await sock.sendMessage(chatId, {
39 text: 'Please provide text or reply to a message to convert.\nExample: `.smallcaps Hello World`'
40 }, { quoted: message });
41 }
42
43 const capsMap: Record<string, any> = {
44 'a': 'ᴀ', 'b': 'ʙ', 'c': 'ᴄ', 'd': 'ᴅ', 'e': 'ᴇ', 'f': 'ꜰ', 'g': 'ɢ', 'h': 'ʜ', 'i': 'ɪ', 'j': 'ᴊ',
45 'k': 'ᴋ', 'l': 'ʟ', 'm': 'ᴍ', 'n': 'ɴ', 'o': 'ᴏ', 'p': 'ᴘ', 'q': 'ǫ', 'r': 'ʀ', 's': 's', 't': 'ᴛ',
46 'u': 'ᴜ', 'v': 'ᴠ', 'w': 'ᴡ', 'x': 'x', 'y': 'ʏ', 'z': 'ᴢ',
47 'A': 'ᴀ', 'B': 'ʙ', 'C': 'ᴄ', 'D': 'ᴅ', 'E': 'ᴇ', 'F': 'ꜰ', 'G': 'ɢ', 'H': 'ʜ', 'I': 'ɪ', 'J': 'ᴊ',
48 'K': 'ᴋ', 'L': 'ʟ', 'M': 'ᴍ', 'N': 'ɴ', 'O': 'ᴏ', 'P': 'ᴘ', 'Q': 'ǫ', 'R': 'ʀ', 'S': 's', 'T': 'ᴛ',
49 'U': 'ᴜ', 'V': 'ᴠ', 'W': 'ᴡ', 'X': 'x', 'Y': 'ʏ', 'Z': 'ᴢ',
50 '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹'
51 };
52
53 const result = txt.split('').map((char: any) => capsMap[char] || char).join('');
54 await sock.sendMessage(chatId, { text: result }, { quoted: message });
55
56 } catch(err: any) {
57 console.error('SmallCaps Error:', err);
58 await sock.sendMessage(chatId, { text: '❌ Failed to process text.' });
59 }
60 }
61};
62
63/*****************************************************************************

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected