render emojis on sent whisper

This commit is contained in:
hemirt 2018-10-26 17:38:17 +02:00 committed by pajlada
parent 7467e1d0e2
commit c8f85b7755

View file

@ -12,6 +12,7 @@
#include "providers/twitch/TwitchApi.hpp" #include "providers/twitch/TwitchApi.hpp"
#include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp" #include "providers/twitch/TwitchServer.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Paths.hpp" #include "singletons/Paths.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include "util/CombinePath.hpp" #include "util/CombinePath.hpp"
@ -163,38 +164,52 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
continue; continue;
} }
} // twitch emote } // twitch emote
{ // bttv/ffz emote { // bttv/ffz emote
{ if ((emote = bttvemotes.emote({words[i]}))) {
if ((emote = bttvemotes.emote({words[i]}))) { flags = MessageElementFlag::BttvEmote;
flags = MessageElementFlag::BttvEmote; } else if ((emote = ffzemotes.emote({words[i]}))) {
} else if ((emote = ffzemotes.emote({words[i]}))) { flags = MessageElementFlag::FfzEmote;
flags = MessageElementFlag::FfzEmote; }
} if (emote) {
if (emote) { b.emplace<EmoteElement>(emote.get(), flags);
b.emplace<EmoteElement>(emote.get(), flags); continue;
continue; }
} } // bttv/ffz emote
} // bttv/ffz emote { // emoji/text
{ // text for (auto &variant :
b.emplace<TextElement>(words[i], app->emotes->emojis.parse(words[i])) {
MessageElementFlag::Text); constexpr const static struct {
} // text void operator()(EmotePtr emote,
MessageBuilder &b) const
{
b.emplace<EmoteElement>(
emote, MessageElementFlag::EmojiAll);
}
void operator()(const QString &string,
MessageBuilder &b) const
{
b.emplace<TextElement>(
string, MessageElementFlag::Text);
}
} visitor;
boost::apply_visitor(
[&b](auto &&arg) { visitor(arg, b); }, variant);
} // emoji/text
} }
}
b->flags.set(MessageFlag::DoNotTriggerNotification); b->flags.set(MessageFlag::DoNotTriggerNotification);
auto messagexD = b.release(); auto messagexD = b.release();
app->twitch.server->whispersChannel->addMessage(messagexD); app->twitch.server->whispersChannel->addMessage(messagexD);
app->twitch.server->sendMessage("jtv", text); app->twitch.server->sendMessage("jtv", text);
if (getSettings()->inlineWhispers) if (getSettings()->inlineWhispers) {
{ app->twitch.server->forEachChannel(
app->twitch.server->forEachChannel( [&messagexD](ChannelPtr _channel) {
[&messagexD](ChannelPtr _channel) { _channel->addMessage(messagexD);
_channel->addMessage(messagexD); });
});
} }
return ""; return "";