#include "inspircd.h" class ModuleFlipText : public Module { public: std::map flipmap; virtual Version GetVersion() { return Version("Provides a /fliptext command - Syntax: FLIPTEXT [#channel|nick] :message", VF_VENDOR); } void init() { Implementation eventlist[] = { I_OnPreCommand }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); flipmap['!'] = "¡"; // INVERTED EXCLAMATION MARK x00A1 flipmap['"'] = "„"; // DOUBLE LOW-9 QUOTATION MARK x201E flipmap['&'] = "⅋"; // TURNED AMPERSAND x214B flipmap['\''] = ","; // COMMA x002C flipmap['('] = ")"; // RIGHT PARENTHESIS x0029 flipmap[')'] = "("; // LEFT PARENTHESIS x0028 flipmap['.'] = "˙"; // DOT ABOVE x02D9 flipmap['3'] = "Ɛ"; // LATIN CAPITAL LETTER OPEN E x0190 flipmap['4'] = "ᔭ"; // CANADIAN SYLLABICS YA x152D flipmap['6'] = "9"; // DIGIT NINE x0039 flipmap['7'] = "Ɫ"; // LATIN CAPITAL LETTER L WITH MIDDLE TILDE x2C62 flipmap[';'] = "؛"; // ARABIC SEMICOLON x061B flipmap['<'] = ">"; // GREATER-THAN SIGN x003E flipmap['?'] = "¿"; // INVERTED QUESTION MARK x00BF flipmap['A'] = "∀"; // FOR ALL x2200 flipmap['B'] = "q"; // DESERET CAPITAL LETTER BEE x10412 - needs fix flipmap['C'] = "Ↄ"; // ROMAN NUMERAL REVERSED ONE HUNDRED x2183 flipmap['D'] = "◖"; // LEFT HALF BLACK CIRCLE x25D6 flipmap['E'] = "Ǝ"; // LATIN CAPITAL LETTER REVERSED E x018E flipmap['F'] = "Ⅎ"; // TURNED CAPITAL F x2132 flipmap['G'] = "⅁"; // TURNED SANS-SERIF CAPITAL G x2141 flipmap['J'] = "ſ"; // LATIN SMALL LETTER LONG S x017F flipmap['K'] = "⋊ "; // RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT x22CA - improve? flipmap['L'] = "⅂"; // TURNED SANS-SERIF CAPITAL L x2142 flipmap['M'] = "W"; // LATIN CAPITAL LETTER W x0057 flipmap['N'] = "N"; // LATIN LETTER CAPITAL N x004E flipmap['P'] = "Ԁ"; // CYRILLIC CAPITAL LETTER KOMI DE x0500 flipmap['Q'] = "Ό"; // GREEK CAPITAL LETTER OMICRON WITH TONOS x038C flipmap['R'] = "ᴚ"; // LATIN LETTER SMALL CAPITAL TURNED R x1D1A flipmap['T'] = "⊥"; // UP TACK x22A5 flipmap['U'] = "∩"; // INTERSECTION x2229 flipmap['V'] = "ᴧ"; // GREEK LETTER SMALL CAPITAL LAMDA x1D27 flipmap['Y'] = "⅄"; // TURNED SANS-SERIF CAPITAL x2144 flipmap['['] = "]"; // RIGHT SQUARE BRACKET x005D flipmap[']'] = "["; // LEFT SQUARE BRACKET x005B flipmap['_'] = "‾"; // OVERLINE x203E flipmap['a'] = "ɐ"; // LATIN SMALL LETTER TURNED A x0250 flipmap['b'] = "q"; // LATIN SMALL LETTER Q x0071 flipmap['c'] = "ɔ"; // LATIN SMALL LETTER OPEN O x0254 flipmap['d'] = "p"; // LATIN SMALL LETTER P x0070 flipmap['e'] = "ǝ"; // LATIN SMALL LETTER TURNED E x01DD flipmap['f'] = "ɟ"; // LATIN SMALL LETTER DOTLESS J WITH STROKE x025F flipmap['g'] = "ƃ"; // LATIN SMALL LETTER B WITH TOPBAR x0183 flipmap['h'] = "ɥ"; // LATIN SMALL LETTER TURNED H x0265 flipmap['i'] = "ı"; // LATIN SMALL LETTER DOTLESS I x0131 flipmap['j'] = "ɾ"; // LATIN SMALL LETTER R WITH FISHHOOK x027E flipmap['k'] = "ʞ"; // LATIN SMALL LETTER TURNED K x029E flipmap['l'] = "ʃ"; // LATIN SMALL LETTER ESH x0283 flipmap['m'] = "ɯ "; // LATIN SMALL LETTER TURNED M x026F flipmap['n'] = "u"; // LATIN SMALL LETTER U x0075 flipmap['r'] = "ɹ"; // LATIN SMALL LETTER TURNED R x0279 flipmap['t'] = "ʇ"; // LATIN SMALL LETTER TURNED T x0287 flipmap['u'] = "n"; // LATIN SMALL LETTER N x006E flipmap['v'] = "ʌ"; // LATIN SMALL LETTER TURNED V x028C flipmap['w'] = "ʍ"; // LATIN SMALL LETTER TURNED W x028D flipmap['y'] = "ʎ"; // LATIN SMALL LETTER TURNED Y x028E flipmap['{'] = "}"; // RIGHT CURLY BRACKET x007D flipmap['}'] = "{"; // LEFT CURLY BRACKET x007B } virtual ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) { /* If theyre not registered yet we dont want to know. */ if (user->registered != REG_ALL) return MOD_RES_PASSTHRU; if (command == "FLIPTEXT") { std::vector newparams; std::string buf; if (parameters.size() < 2) return MOD_RES_DENY; for (size_t i = 1; i < parameters.size(); ++i) { if (buf.empty()) buf = parameters[i]; else buf += " " + parameters[i]; } newparams.push_back(parameters[0]); newparams.push_back(fliptext(buf)); ServerInstance->Parser->CallHandler("PRIVMSG", newparams, user); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; } std::string fliptext(std::string &text) { std::string flipped; std::map::iterator it; /* write backwards */ for (std::string::const_reverse_iterator rit = text.rbegin(); rit != text.rend(); ++rit) { if ((it = flipmap.find(*rit)) != flipmap.end()) flipped += it->second; else flipped += *rit; } return flipped; } }; MODULE_INIT(ModuleFlipText)