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

Function handler

plugins/tinytext.js:21–51  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected