vector font, canApply
This commit is contained in:
parent
e10c407867
commit
034977d53f
11
src/bot.cpp
11
src/bot.cpp
|
@ -5,6 +5,7 @@ using json = nlohmann::json;
|
|||
|
||||
#include "replacefont.h"
|
||||
#include "phonefont.h"
|
||||
#include "vectorfont.h"
|
||||
|
||||
static const std::string fancyrepl[] {"𝓪","𝓫","𝓬","𝓭","𝓮","𝓯","𝓰","𝓱","𝓲","𝓳","𝓴","𝓵","𝓶","𝓷","𝓸","𝓹","𝓺","𝓻","𝓼","𝓽","𝓾","𝓿","𝔀","𝔁","𝔂","𝔃","𝓐","𝓑","𝓒","𝓓","𝓔","𝓕","𝓖","𝓗","𝓘","𝓙","𝓚","𝓛","𝓜","𝓝","𝓞","𝓟","𝓠","𝓡","𝓢","𝓣","𝓤","𝓥","𝓦","𝓧","𝓨","𝓩"};
|
||||
static const std::string frakturrepl[] {"𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅"};
|
||||
|
@ -13,13 +14,14 @@ static const std::string cursedrepl[] {"ǻ̵͙͇̘͕͔̥̣̇̚", "b̶̏̈̏
|
|||
static const std::string monospacere[] {"𝚊", "𝚋", "𝚌", "𝚍", "𝚎", "𝚏", "𝚐", "𝚑", "𝚒", "𝚓", "𝚔", "𝚕", "𝚖", "𝚗", "𝚘", "𝚙", "𝚚", "𝚛", "𝚜", "𝚝", "𝚞", "𝚟", "𝚠", "𝚡", "𝚢", "𝚣", "𝙰", "𝙱", "𝙲", "𝙳", "𝙴", "𝙵", "𝙶", "𝙷", "𝙸", "𝙹", "𝙺", "𝙻", "𝙼", "𝙽", "𝙾", "𝙿", "𝚀", "𝚁", "𝚂", "𝚃", "𝚄", "𝚅", "𝚆", "𝚇", "𝚈", "𝚉"};
|
||||
|
||||
FontBot::FontBot() {
|
||||
fonts.reserve(6);
|
||||
fonts.reserve(7);
|
||||
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());
|
||||
fonts.push_back(new ReplaceFont("monospace", monospacere));
|
||||
fonts.push_back(new VectorFont());
|
||||
}
|
||||
|
||||
FontBot::~FontBot() {
|
||||
|
@ -29,10 +31,17 @@ FontBot::~FontBot() {
|
|||
}
|
||||
|
||||
bool FontBot::handleInline(TelegramAPI::Manager* api, TelegramAPI::InlineQuery& q) {
|
||||
if(q.query.empty()) return true;
|
||||
|
||||
// awnser
|
||||
json arr = {};
|
||||
|
||||
uint8_t id = 1;
|
||||
for(const Font* f : fonts) {
|
||||
// skip font if it can not be applied
|
||||
if(!f->canApply(q.query)) continue;
|
||||
|
||||
// apply font
|
||||
std::string fontized;
|
||||
json j;
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@ public:
|
|||
virtual ~Font() {}
|
||||
virtual void applyFont(const std::string& in, std::string& out) const = 0;
|
||||
virtual const std::string& getName() const = 0;
|
||||
virtual bool canApply(const std::string& in) const = 0;
|
||||
};
|
|
@ -29,4 +29,8 @@ void PhoneFont::applyFont(const std::string& in, std::string& out) const {
|
|||
const std::string& PhoneFont::getName() const {
|
||||
static const std::string name = "Old Phone";
|
||||
return name;
|
||||
}
|
||||
|
||||
bool PhoneFont::canApply(const std::string& in) const {
|
||||
return true;
|
||||
}
|
|
@ -8,6 +8,7 @@ public:
|
|||
|
||||
virtual void applyFont(const std::string& in, std::string& out) const override;
|
||||
virtual const std::string& getName() const override;
|
||||
virtual bool canApply(const std::string& in) const override;
|
||||
private:
|
||||
static const std::string phonePad[];
|
||||
};
|
|
@ -19,4 +19,8 @@ void ReplaceFont::applyFont(const std::string& in, std::string& out) const {
|
|||
|
||||
const std::string& ReplaceFont::getName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ReplaceFont::canApply(const std::string& in) const {
|
||||
return true;
|
||||
}
|
|
@ -8,6 +8,7 @@ public:
|
|||
|
||||
virtual void applyFont(const std::string& in, std::string& out) const override;
|
||||
virtual const std::string& getName() const override;
|
||||
virtual bool canApply(const std::string& in) const override;
|
||||
private:
|
||||
const std::string name;
|
||||
const std::string* repl; //pointer (array)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include "vectorfont.h"
|
||||
|
||||
const std::string VectorFont::vectorSymbol = "⃗";
|
||||
|
||||
VectorFont::VectorFont() {}
|
||||
|
||||
void VectorFont::applyFont(const std::string& in, std::string& out) const {
|
||||
out = in[0] + vectorSymbol;
|
||||
}
|
||||
|
||||
const std::string& VectorFont::getName() const {
|
||||
static const std::string name = "Vector";
|
||||
return name;
|
||||
}
|
||||
|
||||
bool VectorFont::canApply(const std::string& in) const {
|
||||
return in.length() == 1;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "font.h"
|
||||
|
||||
class VectorFont : public Font {
|
||||
public:
|
||||
VectorFont();
|
||||
|
||||
virtual void applyFont(const std::string& in, std::string& out) const override;
|
||||
virtual const std::string& getName() const override;
|
||||
virtual bool canApply(const std::string& in) const override;
|
||||
private:
|
||||
static const std::string vectorSymbol;
|
||||
};
|
Loading…
Reference in New Issue