diff --git a/Makefile b/Makefile index 628480b..4e42bc8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ NAME = fontbot NAMETEST = test -CFLAGS = -std=c++17 -O2 -g -pipe -Wall -Wextra -Wno-unused-parameter -Wpedantic -rdynamic #-march=native -Wall +CFLAGS = -std=c++17 -O2 -pipe -Wall -Wextra -Wno-unused-parameter -Wpedantic -rdynamic #-march=native -Wall CXX = g++ SRCF = src/ BUILDDIR = build/ diff --git a/src/bot.cpp b/src/bot.cpp index eb71a14..5a21894 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -4,6 +4,7 @@ using json = nlohmann::json; #include "replacefont.h" +#include "phonefont.h" static const std::string fancyrepl[] {"𝓪","𝓫","𝓬","𝓭","𝓮","𝓯","𝓰","𝓱","𝓲","𝓳","𝓴","𝓵","𝓶","𝓷","𝓸","𝓹","𝓺","𝓻","𝓼","𝓽","𝓾","𝓿","𝔀","𝔁","𝔂","𝔃","𝓐","𝓑","𝓒","𝓓","𝓔","𝓕","𝓖","𝓗","𝓘","𝓙","𝓚","𝓛","𝓜","𝓝","𝓞","𝓟","𝓠","𝓡","𝓢","𝓣","𝓤","𝓥","𝓦","𝓧","𝓨","𝓩"}; static const std::string frakturrepl[] {"𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅"}; @@ -11,11 +12,12 @@ static const std::string doublerepl[] {"𝕒","𝕓","𝕔","𝕕","𝕖","𝕗 static const std::string cursedrepl[] {"ǻ̵͙͇̘͕͔̥̣̇̚", "b̶̛͕͔̦̏̈̏͆̚", "̴̛̻̯̬̟̺̂̀̔̈́́̅̐̽͑͜ç̴̢̮̯̭̘̗̘̄̉̕", "̴̺͎̩͎̣̯̯̮̭̾̐́̅͑͜d̶̢̝̠̳̤͚͙͖͔̬̿̔͗͌̓̈̈̿̽͋̓́̌̎̐͠ͅ", "̴̨̝̯͕̪͕̲̤̯͎̭̺̳̩̯̘̜̖͂̀̈́̑̓͊̐͛̈́͐̈́̆͋̔̀̓̚͠ȩ̷͈̟̠̣̗̣̭̖̟̀̈́̀͐͆͆̍̀̈́͋̈́͋̎̊̑̈͌͐̏̚", "̷̟͖̺̖̺͍̼͖̣̺͊̄̐f̶̟̪̤̰̘̈́͐̈́́͗̓̒̌̅́̈́͛̄̎̔͑̚̚͜͝͝", "̵̡̢̧͓̩̬̳̭̲͕͈̲̟͚̭̟̮̓͑̌g̷̹̝̘̥̉͐́̓̄̊̔̓̌̆̊͒͊̔̑͘͝͠ͅ", "̷͈͂̔̔̎̉͝h̸̢͓͇̯͚̼͓̋̆͑͜", "̵̧̛̻̼̳̪͉̰͕̝͎̼̈͆̉͛̑̋̒̈̚i̶̡͚̱̟̘̠͙̪̽̆̎̊̓̂̐̂́̌̃̈́̔͋͋͝", "̶͎̻͎͇͛̕ĵ̷̡̧̧̞̬̩̰̩̘͔͈̟̭̩̻̣̣̰̐͑̀̇̀̂͌̾̽̕͜ͅ", "̸͎̥̒͂̐̾͋̔͗́̊̒̽̈̑̌̅̿̀͘k̵̡͈̠̙̖̙̖͖̝̭̘̺̠̺͓̻͎̟̼̇͛", "̵̡̧̢̨̼̳̩̣͚̠̠͎̘̳̻̱̳̥̳̽͐̊͗̍͝ͅl̴̡̨̗͍͕̦̲̝͚̼͎̤̱͍̈̌̃̇͋̌̕͝͝͝", "̵̻̐̒̍͋͂̎̉̚͠͠m̴̤̪͍̲̤̪̺̟̦̠̗͎̎̑̂̅̄͋͛̒̿͛͘͝ͅ", "̶̡̡̝̥̱̬͓̜̖͙̥̰̣͉͇͒̔͜n̶̡̺͔̱̱̤̗̅͌̈́̈́̑̃͗̏̃̈̈́͆̈́̅̒͝", "̶̡̨̮̭̩̘̲͚͚̩̝̙̩̟̞͈͔̟͓̇̾͂̑̿̅̐͝ơ̵̛̜̯̜̾͑͐̍͌̓̅̚̕͠", "̴̪̪̍̅̈̉͂̆̕̕͠p̸̖͉̗̝͚̍̀̑̾̓̍̍̈̍̐̎͛͌̀̈́̓͝ͅ", "̴̨̧̠̹̩̘̦̹̱̌͛̋̕͝͠ͅq̷̡̛͔͙̼͕̲̥̲̪̭̻͈̦̻͈̳͒͂̈́̈́̓̈́͊̈͘̕͜͜ͅ", "̵̛̺̼̔̒̑̽̈̈́͋͒̀͊̀́͊ŗ̸̪̼̹͂̉̒̂̒͑͆̂̽̉̀̃", "̷̰̭̗̻̼̭̰̐̈́̔̑̂̈́̍̈́̌̚͜͠s̸̝̠̦̔̓͛̽̉̃͝͠", "̸͎̙̣͚̯̝̙̜̱̼͕̔̀t̷̹̯͗͂͑̇̉̎̒͌̒͑̋͆̽̀͘͝", "̶̧̪̼̘̙̣̹̩̣̲̥̘͎̣̄̊͠ų̶̭̟̫̩̦̞̱̥̟̗̬̥̦͛̄̈́̉̿̓̇̾͋͑̄́̈́̂͛̏̌͜͠͝ͅ", "̴̢̡̛̠̙̤̹͔̜͈͍̖͖̰̮̬̝̳̀̽̍̽̑̒͆̿̒͗͊͋͋̍̌ͅv̶̢̝̼̰̤͉̙̯͕̣̬͚̮̘̝̱͔̉̽̄̀̾̿̔͊̃͑̒̾̇̊̀͒͘͜͜͝͠͝ͅ", "̷̧̡̛͓̯̥̳͈̭̣̘̐̋́́̀̅̈́̈́̎̈́̿͛̒̒͘͝͝w̶̨͇̞̖̠̣̮̥̻̞̪͚͕͙͎͎̐̄̀͒̍́̽̔̑̌̄̽̐̑̈́̚͜͝", "̷͎̮͍͝x̷̥͕͙̳̦̬̗͉̝͉̺̞̏̌̂͊͊̈́̈̍͘͜", "̸͉̘̺͉̩̗̼̥̯̩̻̟̽̑́͂̎͐̔̂̄̉̐͛̅̍̽́̚͝y̸̨̤̺͎͓̰̠̲̺̰̟͕͉̝̣̻̬͍̼͛͐̑̎͒̀̔͆̀̀̓̽͊̌̒͘", "̶̨͖̘̭̮̤̫͎̹̫̺̗̿͊̅͒́̀̈́̾́̿̔̅̋̑̀͋́͑̚͝z̶͍̀̒̐͐̎͛̃̄́̈́̏̀́̎̎̃̄̕̕", "A̵̡͖͙̟̯̯̐͑̄̾͗̓͝", "̵̦̗̘̣̓̾̐̑̃͌̂͂̂̈̏̈́̍̈́̚͠͠ͅB̴̨̨̢̭̱̳̳͕͓̗̦͔̥͊̌̂̊͌̀̎̇̍́͒͊̑̂͜͠", "̴̘͇̩̮̺͒́̾̒́͗͒͋̎̔̅̀̀̆͜͝C̶͓̹̮̟͓͎̳͈̻̻̿̅̎̊̽̀͐̅͘͜͝͝͝͠", "̶̧̛̞͓̹̺͖̣̜̮̼̥̠̣̖͈͍̜̯͓̀͊̈͐͒ͅD̴̡̡̅͠", "̴̨͕̺̝̙̰̭̫̈̀͛͑͐͒̀̕Ȩ̴̢̛͔̦͇̬̱̰̙̮̬̗̥̦̄̿̒̎̉͋̃̓́̐̉́̍̿͘", "̸͈̻̮̟̅̔̇̈͐͛̍̐̄̒̓̌̑͑̔̎͘͜ͅF̵̛̞̬͎̳̖̥̈̓̓", "̷̡̜̼̝̩̣̙͙̫̜͕̬̻̈̇̄͗̓̇͘͜͜G̵̛̳͈̥̼̣̾͛̉̋͐̐̑̅̅͝", "̴̛̮̖̼̞͉̩̩͔̤̣̿́͗͋͋̚͜͜Ḥ̵̡̨̩͎̦̲̦̗̮̲̳͈̦̦̙͉̓̇̊́͊͗̚ͅ", "̴̠̠̝̲̹̮̖̳̹̫̘̇̀͝", "̶̨͓̥͉̝̘̝̮̼͙͍͒͆̆̉̓́̔̋̽̾̈̏̾̕I̸̢̢̙̲̲̣̩̻̣̓͌͂̏̂̅̈́̈́́̊̏̒̌͝͝ͅ", "̶̛̼̳̮̂͂̅͌̒̌͊̉͂͑̑́̇̃̕͝͝J̵̺̫̝͍̹̪͉̪̽͌̓̿͂̿͗̎̚̚͝", "̵̛̞͓̪̦̮͙̘͙͖̥̻͓̗̮̦̞̻͓̦̓̃̂͑̾͑̚Ǩ̵̡̡͍̪͔͉͔̠̻̗̝̹̥̤̺͎͋̀̀̓̐͑̽͐̒̍͘͜", "̵̞̹̳͉̮͖̫̪͂̾̓̑̀̄̐͊L̵̛͎̺̝͔̠͇͈͇̰͚͓̊͑̓̐̽͆̉͛̇̌͛̅͊͝͠͝͠", "̵̡̨̨͔̺̫̬̰̈́͊̿̃̚͠M̴̧͔̗̤̝̲̝̹̤͙̺̿̅̔͋̒̎̓̓̈́̇͑̈́̚̕͝͠", "̵̙̠͈͈̖͕̣͕̲̖̄̈́̀̽͂͋̑̃͋͜ͅŅ̷̢͈̜̦̑̓̓̓̒", "̵̨̛͉̭͓̟̼̹̥̖̥̖̼̥̠̩͉͓̟̔̃͐̇̉̅̂͒̍̏̃Ò̷̡̟̭͈̜̼̳̤̪͖̰͎̘̩̜̰̫̱̹͎̓", "̷̘͕͉̲̯̊̔̒̏͌̈͐̅̾͒͆̾̄́̂̑̚͝P̸̺̫̆̍͌̇͛̀̏", "̶̢͍̹͔̦̟̣͔̠͇̯͓̎̇̀͋̓̉̈́̓͘͜͜Q̷̨̧̛̛̻͕̬͖̘̳̤̎̎̀̑͑̃̔͒̇̈́̌́̀̂̋͘̕", "̷͖̥̺͙̯͉͋̐Ŕ̷̡̨̡̬̥̳͎̭̮̬̩̫̈͑̒̔̔́̌̍͌͋̽̈͌̚͜͝", "̸̛͉̰̫̈́̄͂̿̄̈́͆́̽͝͠S̷͔̱̝̘̭̘̮̮̦̣̟̼̊̀̏̄̆̏̾̋́̾͗̏͝ͅ", "̸̧̛͍̝̭̫̙̫͖͕͉͇͌̔̀̈̓̊̅̅̚T̵̛͍͉͉̥̞̞͚̮̺̜͓̲̥̽̈́͗̌͗͗͊̓̄̽͂͆̿́̉̚͜", "̶̯̣͉̦̰̗̝̩̭̜̘̦̫̖̟͈̜̥̃̿̀͊̔͜U̶̦͚͕̰̻̺̙̙͕̔̿͂̌̏̀͆̉", "̶̜̳̯̫̖̘̦̜̘̤̘͓͔͕̞̦͖̀̈̐͋̾̀̆̾̇̋̕͝͠V̷̡̻͎̞̼̤̫̫̲̳̜̪͙͓̰͇͌̀͋́͛͗̍̓͘͜", "̶̡̢̝̺͕͈̬͓̹͇̩̻̖͕̪̞̿̑̐̓̄̊̊̾͘W̶̜̰̗̬̄̂͗̀̅̔̊̍̆͗̓̑̐̕", "̴̡̡̛̘͓̱͕͚͚̲̱̺̰͈̫̹̒̐́͆̄̔͆̈́̀͂͘͘͠ͅX̷̰̿͒̎̎̍̀̚", "̶̞͖̜̘̬͉̗͚̝͔̤̲̣͗̑̈́͆̉̋̑̆̊́̓̀̄̊̈Y̶̢̢̝̻̞̖̤̰͇̐̆͋̅͆̍̀͜͜", "̴͎̼̠͕̬̰̯̲̬͔̖̦͖̜͕̙͋̏͂͜͠Z̷̢̡̛͖̩̟̬͔̝̫̭̼͐́̈́̉́̎̍͠"}; FontBot::FontBot() { - fonts.reserve(4); + fonts.reserve(5); fonts.push_back(new ReplaceFont("Fancy", fancyrepl)); fonts.push_back(new ReplaceFont("Fraktur", frakturrepl)); fonts.push_back(new ReplaceFont("Double", doublerepl)); fonts.push_back(new ReplaceFont("Cursed", cursedrepl)); + fonts.push_back(new PhoneFont()); } FontBot::~FontBot() { diff --git a/src/phonefont.cpp b/src/phonefont.cpp new file mode 100644 index 0000000..19d5682 --- /dev/null +++ b/src/phonefont.cpp @@ -0,0 +1,32 @@ +#include "phonefont.h" + +const std::string PhoneFont::phonePad[] = {"2", "22", "222", "3", "33", "333", "4", "44", "444", "5", "55", "555", "6", "66", "666", "7", "77", "777", "7777", "8", "88", "888", "9", "99", "999", "9999"}; + +PhoneFont::PhoneFont() {} + +void PhoneFont::applyFont(const std::string& in, std::string& out) const { + bool wasPrevSpace = true; + for(size_t pos_in = 0; pos_in < in.size(); ++pos_in) { + char c = in[pos_in]; + bool isSpace = std::isspace(c); + + if(!wasPrevSpace && !isSpace) { + out += '-'; + } + + if(c >= 'a' && c <= 'z') { + out += phonePad[c - 'a']; + } else if(c >= 'A' && c <= 'Z') { + out += phonePad[c - 'A']; + } else { + out += c; + } + + wasPrevSpace = isSpace; + } +} + +const std::string& PhoneFont::getName() const { + static const std::string name = "Old Phone"; + return name; +} \ No newline at end of file diff --git a/src/phonefont.h b/src/phonefont.h new file mode 100644 index 0000000..cbfaccc --- /dev/null +++ b/src/phonefont.h @@ -0,0 +1,13 @@ +#pragma once + +#include "font.h" + +class PhoneFont : public Font { +public: + PhoneFont(); + + virtual void applyFont(const std::string& in, std::string& out) const override; + virtual const std::string& getName() const override; +private: + static const std::string phonePad[]; +}; \ No newline at end of file