mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
render bttv/ffz global emotes in incoming whispers, bttv/ffz/twitch (#824)
emotes in outgoing whispers
This commit is contained in:
parent
02eeedb338
commit
c176d836af
4 changed files with 62 additions and 8 deletions
|
@ -148,14 +148,40 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
|||
MessageColor::Text,
|
||||
FontStyle::ChatMediumBold);
|
||||
|
||||
QString rest = "";
|
||||
|
||||
for (int i = 2; i < words.length(); i++)
|
||||
{
|
||||
rest += words[i] + " ";
|
||||
const auto &acc = app->accounts->twitch.getCurrent();
|
||||
const auto &accemotes = *acc->accessEmotes();
|
||||
const auto &bttvemotes = app->twitch.server->getBttvEmotes();
|
||||
const auto &ffzemotes = app->twitch.server->getFfzEmotes();
|
||||
auto flags = MessageElementFlags();
|
||||
auto emote = boost::optional<EmotePtr>{};
|
||||
for (int i = 2; i < words.length(); i++) {
|
||||
{ // twitch emote
|
||||
auto it = accemotes.emotes.find({words[i]});
|
||||
if (it != accemotes.emotes.end()) {
|
||||
b.emplace<EmoteElement>(
|
||||
it->second, MessageElementFlag::TwitchEmote);
|
||||
continue;
|
||||
}
|
||||
} // twitch emote
|
||||
{ // bttv/ffz emote
|
||||
{
|
||||
if ((emote = bttvemotes.emote({words[i]}))) {
|
||||
flags = MessageElementFlag::BttvEmote;
|
||||
} else if ((emote = ffzemotes.emote({words[i]}))) {
|
||||
flags = MessageElementFlag::FfzEmote;
|
||||
}
|
||||
if (emote) {
|
||||
b.emplace<EmoteElement>(emote.get(), flags);
|
||||
continue;
|
||||
}
|
||||
} // bttv/ffz emote
|
||||
{ // text
|
||||
b.emplace<TextElement>(words[i],
|
||||
MessageElementFlag::Text);
|
||||
} // text
|
||||
}
|
||||
}
|
||||
|
||||
b.emplace<TextElement>(rest, MessageElementFlag::Text);
|
||||
b->flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
auto messagexD = b.release();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "providers/chatterino/ChatterinoBadges.hpp"
|
||||
#include "providers/twitch/TwitchBadges.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
@ -986,8 +987,23 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
|||
{
|
||||
// Special channels, like /whispers and /channels return here
|
||||
// This means they will not render any BTTV or FFZ emotes
|
||||
if (this->twitchChannel == nullptr)
|
||||
{
|
||||
if (this->twitchChannel == nullptr) {
|
||||
auto *app = getApp();
|
||||
const auto &bttvemotes = app->twitch.server->getBttvEmotes();
|
||||
const auto &ffzemotes = app->twitch.server->getFfzEmotes();
|
||||
auto flags = MessageElementFlags();
|
||||
auto emote = boost::optional<EmotePtr>{};
|
||||
{ // bttv/ffz emote
|
||||
if ((emote = bttvemotes.emote(name))) {
|
||||
flags = MessageElementFlag::BttvEmote;
|
||||
} else if ((emote = ffzemotes.emote(name))) {
|
||||
flags = MessageElementFlag::FfzEmote;
|
||||
}
|
||||
if (emote) {
|
||||
this->emplace<EmoteElement>(emote.get(), flags);
|
||||
return Success;
|
||||
}
|
||||
} // bttv/ffz emote
|
||||
return Failure;
|
||||
}
|
||||
|
||||
|
|
|
@ -288,4 +288,13 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel,
|
|||
sent = true;
|
||||
}
|
||||
|
||||
const BttvEmotes &TwitchServer::getBttvEmotes() const
|
||||
{
|
||||
return this->bttv;
|
||||
}
|
||||
const FfzEmotes &TwitchServer::getFfzEmotes() const
|
||||
{
|
||||
return this->ffz;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
|
||||
PubSub *pubsub;
|
||||
|
||||
const BttvEmotes &getBttvEmotes() const;
|
||||
const FfzEmotes &getFfzEmotes() const;
|
||||
|
||||
protected:
|
||||
virtual void initializeConnection(IrcConnection *connection, bool isRead,
|
||||
bool isWrite) override;
|
||||
|
|
Loading…
Reference in a new issue