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,8 +164,8 @@ 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]}))) {
@ -175,11 +176,26 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
continue; continue;
} }
} // bttv/ffz emote } // bttv/ffz emote
{ // text { // emoji/text
b.emplace<TextElement>(words[i], for (auto &variant :
MessageElementFlag::Text); app->emotes->emojis.parse(words[i])) {
} // text constexpr const static struct {
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);
@ -189,8 +205,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
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);