mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
broken commit
This commit is contained in:
parent
6f04a3ad6d
commit
49f3a41b7e
43
channel.cpp
43
channel.cpp
|
@ -1,7 +1,15 @@
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
#include "emotes.h"
|
||||||
#include "messages/message.h"
|
#include "messages/message.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -27,9 +35,10 @@ Channel::Channel(const QString &channel)
|
||||||
void
|
void
|
||||||
Channel::reloadBttvEmotes()
|
Channel::reloadBttvEmotes()
|
||||||
{
|
{
|
||||||
|
// bttv
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager();
|
QNetworkAccessManager *manager = new QNetworkAccessManager();
|
||||||
|
|
||||||
QUrl url("https://api.frankerfacez.com/v1/set/global");
|
QUrl url("https://api.betterttv.net/2/channels/" + this->name);
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
|
||||||
QNetworkReply *reply = manager->get(request);
|
QNetworkReply *reply = manager->get(request);
|
||||||
|
@ -40,26 +49,26 @@ Channel::reloadBttvEmotes()
|
||||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
|
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
|
||||||
QJsonObject root = jsonDoc.object();
|
QJsonObject root = jsonDoc.object();
|
||||||
|
|
||||||
auto sets = root.value("sets").toObject();
|
auto emotes = root.value("emotes").toArray();
|
||||||
|
|
||||||
for (const QJsonValue &set : sets) {
|
QString _template = "https:" + root.value("urlTemplate").toString();
|
||||||
auto emoticons = set.toObject().value("emoticons").toArray();
|
|
||||||
|
|
||||||
for (const QJsonValue &emote : emoticons) {
|
for (const QJsonValue &emote : emotes) {
|
||||||
QJsonObject object = emote.toObject();
|
QString id = emote.toObject().value("id").toString();
|
||||||
|
QString code = emote.toObject().value("code").toString();
|
||||||
|
// emote.value("imageType").toString();
|
||||||
|
|
||||||
// margins
|
QString tmp = _template;
|
||||||
|
tmp.detach();
|
||||||
|
QString url =
|
||||||
|
tmp.replace("{{id}}", id).replace("{{image}}", "1x");
|
||||||
|
|
||||||
int id = object.value("id").toInt();
|
this->getBttvChannelEmotes().insert(
|
||||||
QString code = object.value("name").toString();
|
code,
|
||||||
|
Emotes::getBttvChannelEmoteFromCaches().getOrAdd(id, [=] {
|
||||||
QJsonObject urls = object.value("urls").toObject();
|
return new messages::LazyLoadedImage(
|
||||||
QString url1 = "http:" + urls.value("1").toString();
|
url, 1, code, code + "\nChannel Bttv Emote");
|
||||||
|
}));
|
||||||
Emotes::getBttvEmotes().insert(
|
|
||||||
code, new messages::LazyLoadedImage(
|
|
||||||
url1, 1, code, code + "\nGlobal Ffz Emote"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ public:
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
const ConcurrentMap<QString, messages::LazyLoadedImage *> &
|
const ConcurrentMap<QString, messages::LazyLoadedImage *> &
|
||||||
getBttvChannelEmotes() const
|
getBttvChannelEmotes()
|
||||||
{
|
{
|
||||||
return bttvChannelEmotes;
|
return bttvChannelEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConcurrentMap<QString, messages::LazyLoadedImage *> &
|
const ConcurrentMap<QString, messages::LazyLoadedImage *> &
|
||||||
getFfzChannelEmotes() const
|
getFfzChannelEmotes()
|
||||||
{
|
{
|
||||||
return ffzChannelEmotes;
|
return ffzChannelEmotes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ Message::Message(const QString &text)
|
||||||
QString()));
|
QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
Message::Message(const IrcPrivateMessage &ircMessage, Channel &channel,
|
||||||
bool enablePingSound, bool isReceivedWhisper,
|
bool enablePingSound, bool isReceivedWhisper,
|
||||||
bool isSentWhisper, bool includeChannel)
|
bool isSentWhisper, bool includeChannel)
|
||||||
: wordParts()
|
: wordParts()
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Message(const QString &text);
|
Message(const QString &text);
|
||||||
Message(const IrcPrivateMessage &ircMessage, const Channel &Channel,
|
Message(const IrcPrivateMessage &ircMessage, Channel &Channel,
|
||||||
bool enablePingSound = true, bool isReceivedWhisper = false,
|
bool enablePingSound = true, bool isReceivedWhisper = false,
|
||||||
bool isSentWhisper = false, bool includeChannel = false);
|
bool isSentWhisper = false, bool includeChannel = false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue