FontBot/src/bot.cpp

49 lines
6.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "bot.h"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
#include "replacefont.h"
static const std::string fancyrepl[] {"𝓪","𝓫","𝓬","𝓭","𝓮","𝓯","𝓰","𝓱","𝓲","𝓳","𝓴","𝓵","𝓶","𝓷","𝓸","𝓹","𝓺","𝓻","𝓼","𝓽","𝓾","𝓿","𝔀","𝔁","𝔂","𝔃","𝓐","𝓑","𝓒","𝓓","𝓔","𝓕","𝓖","𝓗","𝓘","𝓙","𝓚","𝓛","𝓜","𝓝","𝓞","𝓟","𝓠","𝓡","𝓢","𝓣","𝓤","𝓥","𝓦","𝓧","𝓨","𝓩"};
static const std::string frakturrepl[] {"𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅"};
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.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));
}
FontBot::~FontBot() {
for(Font* f : fonts) {
delete f;
}
}
bool FontBot::handleInline(TelegramAPI::Manager* api, TelegramAPI::InlineQuery& q) {
json arr = {};
uint8_t id = 1;
for(const Font* f : fonts) {
std::string fontized;
json j;
f->applyFont(q.query, fontized);
j["type"] = "article";
j["id"] = id++;
j["title"] = f->getName();
j["description"] = fontized;
j["message_text"] = fontized;
arr.push_back(j);
}
// Log::info << arr;
api->answerInlineQuery(q.id, arr, 86400*7); //cache for a week
return true;
}