Switch to QT Category logging (#2206)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "IvrApi.hpp"
|
||||
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
#include <QUrlQuery>
|
||||
|
||||
@@ -23,8 +24,9 @@ void IvrApi::getSubage(QString userName, QString channelName,
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](NetworkResult result) {
|
||||
qDebug() << "Failed IVR API Call!" << result.status()
|
||||
<< QString(result.getData());
|
||||
qCWarning(chatterinoIvr)
|
||||
<< "Failed IVR API Call!" << result.status()
|
||||
<< QString(result.getData());
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "common/NetworkRequest.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/ImageSet.hpp"
|
||||
@@ -178,15 +179,17 @@ void BttvEmotes::loadChannel(std::weak_ptr<Channel> channel,
|
||||
else if (result.status() == NetworkResult::timedoutStatus)
|
||||
{
|
||||
// TODO: Auto retry in case of a timeout, with a delay
|
||||
qDebug() << "Fetching BTTV emotes for channel" << channelId
|
||||
<< "failed due to timeout";
|
||||
qCWarning(chatterinoBttv)
|
||||
<< "Fetching BTTV emotes for channel" << channelId
|
||||
<< "failed due to timeout";
|
||||
shared->addMessage(makeSystemMessage(
|
||||
"Failed to fetch BetterTTV channel emotes. (timed out)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Error fetching BTTV emotes for channel"
|
||||
<< channelId << ", error" << result.status();
|
||||
qCWarning(chatterinoBttv)
|
||||
<< "Error fetching BTTV emotes for channel" << channelId
|
||||
<< ", error" << result.status();
|
||||
shared->addMessage(
|
||||
makeSystemMessage("Failed to fetch BetterTTV channel "
|
||||
"emotes. (unknown error)"));
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QFile>
|
||||
#include <boost/variant.hpp>
|
||||
#include <memory>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
@@ -131,9 +132,9 @@ void Emojis::loadEmojis()
|
||||
|
||||
if (result.Code() != rapidjson::kParseErrorNone)
|
||||
{
|
||||
qDebug() << "JSON parse error:"
|
||||
<< rapidjson::GetParseError_En(result.Code()) << "("
|
||||
<< result.Offset() << ")";
|
||||
qCWarning(chatterinoEmoji)
|
||||
<< "JSON parse error:" << rapidjson::GetParseError_En(result.Code())
|
||||
<< "(" << result.Offset() << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,8 +166,9 @@ void Emojis::loadEmojis()
|
||||
auto toneNameIt = toneNames.find(tone);
|
||||
if (toneNameIt == toneNames.end())
|
||||
{
|
||||
qDebug() << "Tone with key" << tone.c_str()
|
||||
<< "does not exist in tone names map";
|
||||
qCDebug(chatterinoEmoji)
|
||||
<< "Tone with key" << tone.c_str()
|
||||
<< "does not exist in tone names map";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "common/NetworkRequest.hpp"
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
@@ -195,8 +196,8 @@ void FfzEmotes::loadChannel(
|
||||
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback,
|
||||
bool manualRefresh)
|
||||
{
|
||||
qDebug() << "[FFZEmotes] Reload FFZ Channel Emotes for channel"
|
||||
<< channelId;
|
||||
qCDebug(chatterinoFfzemotes)
|
||||
<< "[FFZEmotes] Reload FFZ Channel Emotes for channel" << channelId;
|
||||
|
||||
NetworkRequest("https://api.frankerfacez.com/v1/room/id/" + channelId)
|
||||
|
||||
@@ -230,16 +231,18 @@ void FfzEmotes::loadChannel(
|
||||
else if (result.status() == NetworkResult::timedoutStatus)
|
||||
{
|
||||
// TODO: Auto retry in case of a timeout, with a delay
|
||||
qDebug() << "Fetching FFZ emotes for channel" << channelId
|
||||
<< "failed due to timeout";
|
||||
qCWarning(chatterinoFfzemotes)
|
||||
<< "Fetching FFZ emotes for channel" << channelId
|
||||
<< "failed due to timeout";
|
||||
shared->addMessage(
|
||||
makeSystemMessage("Failed to fetch FrankerFaceZ channel "
|
||||
"emotes. (timed out)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Error fetching FFZ emotes for channel" << channelId
|
||||
<< ", error" << result.status();
|
||||
qCWarning(chatterinoFfzemotes)
|
||||
<< "Error fetching FFZ emotes for channel" << channelId
|
||||
<< ", error" << result.status();
|
||||
shared->addMessage(
|
||||
makeSystemMessage("Failed to fetch FrankerFaceZ channel "
|
||||
"emotes. (unknown error)"));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
@@ -76,7 +77,8 @@ AbstractIrcServer::AbstractIrcServer()
|
||||
|
||||
if (!this->readConnection_->isConnected())
|
||||
{
|
||||
qDebug() << "Trying to reconnect..." << this->falloffCounter_;
|
||||
qCDebug(chatterinoIrc)
|
||||
<< "Trying to reconnect..." << this->falloffCounter_;
|
||||
this->connect();
|
||||
}
|
||||
});
|
||||
@@ -195,8 +197,8 @@ ChannelPtr AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
|
||||
chan->destroyed.connect([this, channelName] {
|
||||
// fourtf: issues when the server itself is destroyed
|
||||
|
||||
qDebug() << "[AbstractIrcServer::addChannel]" << channelName
|
||||
<< "was destroyed";
|
||||
qCDebug(chatterinoIrc) << "[AbstractIrcServer::addChannel]"
|
||||
<< channelName << "was destroyed";
|
||||
this->channels.remove(channelName);
|
||||
|
||||
if (this->readConnection_)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/irc/Irc2.hpp"
|
||||
#include "providers/irc/IrcChannel2.hpp"
|
||||
@@ -187,7 +188,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "message ignored :rage:";
|
||||
qCDebug(chatterinoIrc) << "message ignored :rage:";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ChannelPointReward.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -9,7 +10,8 @@ QString parseRewardImage(const rapidjson::Value &obj, const char *key,
|
||||
QString url;
|
||||
if (!(result = rj::getSafe(obj, key, url)))
|
||||
{
|
||||
qDebug() << "No url value found for key in reward image object:" << key;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "No url value found for key in reward image object:" << key;
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -22,7 +24,7 @@ ChannelPointReward::ChannelPointReward(rapidjson::Value &redemption)
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafeObject(redemption, "user", user)))
|
||||
{
|
||||
qDebug() << "No user info found for redemption";
|
||||
qCDebug(chatterinoTwitch) << "No user info found for redemption";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,41 +32,42 @@ ChannelPointReward::ChannelPointReward(rapidjson::Value &redemption)
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafeObject(redemption, "reward", reward)))
|
||||
{
|
||||
qDebug() << "No reward info found for redemption";
|
||||
qCDebug(chatterinoTwitch) << "No reward info found for redemption";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully = rj::getSafe(reward, "id", this->id)))
|
||||
{
|
||||
qDebug() << "No id found for reward";
|
||||
qCDebug(chatterinoTwitch) << "No id found for reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafe(reward, "channel_id", this->channelId)))
|
||||
{
|
||||
qDebug() << "No channel_id found for reward";
|
||||
qCDebug(chatterinoTwitch) << "No channel_id found for reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafe(reward, "title", this->title)))
|
||||
{
|
||||
qDebug() << "No title found for reward";
|
||||
qCDebug(chatterinoTwitch) << "No title found for reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafe(reward, "cost", this->cost)))
|
||||
{
|
||||
qDebug() << "No cost found for reward";
|
||||
qCDebug(chatterinoTwitch) << "No cost found for reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully = rj::getSafe(
|
||||
reward, "is_user_input_required", this->isUserInputRequired)))
|
||||
{
|
||||
qDebug() << "No information if user input is required found for reward";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "No information if user input is required found for reward";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,21 +108,21 @@ void ChannelPointReward::parseUser(rapidjson::Value &user)
|
||||
{
|
||||
if (!(this->hasParsedSuccessfully = rj::getSafe(user, "id", this->user.id)))
|
||||
{
|
||||
qDebug() << "No id found for user in reward";
|
||||
qCDebug(chatterinoTwitch) << "No id found for user in reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafe(user, "login", this->user.login)))
|
||||
{
|
||||
qDebug() << "No login name found for user in reward";
|
||||
qCDebug(chatterinoTwitch) << "No login name found for user in reward";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(this->hasParsedSuccessfully =
|
||||
rj::getSafe(user, "display_name", this->user.displayName)))
|
||||
{
|
||||
qDebug() << "No display name found for user in reward";
|
||||
qCDebug(chatterinoTwitch) << "No display name found for user in reward";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Peter Thorson, Steve Wills. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the WebSocket++ Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CHATTERINOWEBSOCKETPPLOGGER_HPP
|
||||
#define CHATTERINOWEBSOCKETPPLOGGER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <websocketpp/common/cpp11.hpp>
|
||||
#include <websocketpp/logger/basic.hpp>
|
||||
#include <websocketpp/logger/levels.hpp>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace websocketpp {
|
||||
namespace log {
|
||||
|
||||
template <typename concurrency, typename names>
|
||||
class chatterinowebsocketpplogger : public basic<concurrency, names>
|
||||
{
|
||||
public:
|
||||
typedef chatterinowebsocketpplogger<concurrency, names> base;
|
||||
|
||||
chatterinowebsocketpplogger<concurrency, names>(
|
||||
channel_type_hint::value)
|
||||
: m_static_channels(0xffffffff)
|
||||
, m_dynamic_channels(0)
|
||||
{
|
||||
}
|
||||
|
||||
chatterinowebsocketpplogger<concurrency, names>(std::ostream *)
|
||||
: m_static_channels(0xffffffff)
|
||||
, m_dynamic_channels(0)
|
||||
{
|
||||
}
|
||||
|
||||
chatterinowebsocketpplogger<concurrency, names>(
|
||||
level c, channel_type_hint::value)
|
||||
: m_static_channels(c)
|
||||
, m_dynamic_channels(0)
|
||||
{
|
||||
}
|
||||
|
||||
chatterinowebsocketpplogger<concurrency, names>(level c, std::ostream *)
|
||||
: m_static_channels(c)
|
||||
, m_dynamic_channels(0)
|
||||
{
|
||||
}
|
||||
|
||||
~chatterinowebsocketpplogger<concurrency, names>()
|
||||
{
|
||||
}
|
||||
|
||||
chatterinowebsocketpplogger<concurrency, names>(
|
||||
chatterinowebsocketpplogger<concurrency, names> const &other)
|
||||
: m_static_channels(other.m_static_channels)
|
||||
, m_dynamic_channels(other.m_dynamic_channels)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
|
||||
chatterinowebsocketpplogger<concurrency, names> &operator=(
|
||||
chatterinowebsocketpplogger<concurrency, names> const &) = delete;
|
||||
#endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
|
||||
|
||||
#ifdef _WEBSOCKETPP_MOVE_SEMANTICS_
|
||||
/// Move constructor
|
||||
chatterinowebsocketpplogger<concurrency, names>(
|
||||
chatterinowebsocketpplogger<concurrency, names> &&other)
|
||||
: m_static_channels(other.m_static_channels)
|
||||
, m_dynamic_channels(other.m_dynamic_channels)
|
||||
{
|
||||
}
|
||||
# ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
|
||||
// no move assignment operator because of const member variables
|
||||
chatterinowebsocketpplogger<concurrency, names> &operator=(
|
||||
chatterinowebsocketpplogger<concurrency, names> &&) = delete;
|
||||
# endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
|
||||
#endif // _WEBSOCKETPP_MOVE_SEMANTICS_
|
||||
|
||||
/// Explicitly do nothing, this logger doesn't support changing ostream
|
||||
void set_ostream(std::ostream *)
|
||||
{
|
||||
}
|
||||
|
||||
/// Dynamically enable the given list of channels
|
||||
/**
|
||||
* @param channels The package of channels to enable
|
||||
*/
|
||||
void set_channels(level channels)
|
||||
{
|
||||
if (channels == names::none)
|
||||
{
|
||||
clear_channels(names::all);
|
||||
return;
|
||||
}
|
||||
|
||||
scoped_lock_type lock(m_lock);
|
||||
m_dynamic_channels |= (channels & m_static_channels);
|
||||
}
|
||||
|
||||
/// Dynamically disable the given list of channels
|
||||
/**
|
||||
* @param channels The package of channels to disable
|
||||
*/
|
||||
void clear_channels(level channels)
|
||||
{
|
||||
scoped_lock_type lock(m_lock);
|
||||
m_dynamic_channels &= ~channels;
|
||||
}
|
||||
|
||||
/// Write a string message to the given channel
|
||||
/**
|
||||
* @param channel The channel to write to
|
||||
* @param msg The message to write
|
||||
*/
|
||||
void write(level channel, std::string const &msg)
|
||||
{
|
||||
scoped_lock_type lock(m_lock);
|
||||
if (!this->dynamic_test(channel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
qCDebug(chatterinoWebsocket).nospace()
|
||||
<< names::channel_name(channel) << ": "
|
||||
<< QString::fromStdString(msg);
|
||||
}
|
||||
|
||||
/// Write a cstring message to the given channel
|
||||
/**
|
||||
* @param channel The channel to write to
|
||||
* @param msg The message to write
|
||||
*/
|
||||
void write(level channel, char const *msg)
|
||||
{
|
||||
scoped_lock_type lock(m_lock);
|
||||
if (!this->dynamic_test(channel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
qCDebug(chatterinoWebsocket).nospace()
|
||||
<< names::channel_name(channel) << ": " << msg;
|
||||
}
|
||||
|
||||
/// Test whether a channel is statically enabled
|
||||
/**
|
||||
* @param channel The package of channels to test
|
||||
*/
|
||||
|
||||
_WEBSOCKETPP_CONSTEXPR_TOKEN_ bool static_test(level channel) const
|
||||
{
|
||||
return ((channel & m_static_channels) != 0);
|
||||
}
|
||||
|
||||
/// Test whether a channel is dynamically enabled
|
||||
/**
|
||||
* @param channel The package of channels to test
|
||||
*/
|
||||
bool dynamic_test(level channel)
|
||||
{
|
||||
return ((channel & m_dynamic_channels) != 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef typename concurrency::scoped_lock_type scoped_lock_type;
|
||||
typedef typename concurrency::mutex_type mutex_type;
|
||||
mutex_type m_lock;
|
||||
|
||||
private:
|
||||
level const m_static_channels;
|
||||
level m_dynamic_channels;
|
||||
};
|
||||
|
||||
} // namespace log
|
||||
} // namespace websocketpp
|
||||
|
||||
#endif // CHATTERINOWEBSOCKETPPLOGGER_HPP
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "IrcMessageHandler.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
@@ -361,8 +362,9 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||
|
||||
if (chan->isEmpty())
|
||||
{
|
||||
qDebug() << "[IrcMessageHandler:handleClearChatMessage] Twitch channel"
|
||||
<< chanName << "not found";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "[IrcMessageHandler:handleClearChatMessage] Twitch channel"
|
||||
<< chanName << "not found";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,9 +429,10 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||
|
||||
if (chan->isEmpty())
|
||||
{
|
||||
qDebug() << "[IrcMessageHandler:handleClearMessageMessage] Twitch "
|
||||
"channel"
|
||||
<< chanName << "not found";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "[IrcMessageHandler:handleClearMessageMessage] Twitch "
|
||||
"channel"
|
||||
<< chanName << "not found";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -712,8 +715,9 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
|
||||
if (channel->isEmpty())
|
||||
{
|
||||
qDebug() << "[IrcManager:handleNoticeMessage] Channel"
|
||||
<< channelName << "not found in channel manager";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "[IrcManager:handleNoticeMessage] Channel" << channelName
|
||||
<< "not found in channel manager";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include <rapidjson/error/en.h>
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
#define TWITCH_PUBSUB_URL "wss://pubsub-edge.twitch.tv"
|
||||
|
||||
@@ -154,7 +156,8 @@ namespace detail {
|
||||
|
||||
if (self->awaitingPong_)
|
||||
{
|
||||
qDebug() << "No pong response, disconnect!";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "No pong response, disconnect!";
|
||||
// TODO(pajlada): Label this connection as "disconnect me"
|
||||
}
|
||||
});
|
||||
@@ -178,8 +181,8 @@ namespace detail {
|
||||
|
||||
if (ec)
|
||||
{
|
||||
qDebug() << "Error sending message" << payload << ":"
|
||||
<< ec.message().c_str();
|
||||
qCDebug(chatterinoPubsub) << "Error sending message" << payload
|
||||
<< ":" << ec.message().c_str();
|
||||
// TODO(pajlada): Check which error code happened and maybe
|
||||
// gracefully handle it
|
||||
|
||||
@@ -193,7 +196,7 @@ namespace detail {
|
||||
|
||||
PubSub::PubSub()
|
||||
{
|
||||
qDebug() << "init PubSub";
|
||||
qCDebug(chatterinoPubsub) << "init PubSub";
|
||||
|
||||
this->moderationActionHandlers["clear"] = [this](const auto &data,
|
||||
const auto &roomID) {
|
||||
@@ -221,7 +224,7 @@ PubSub::PubSub()
|
||||
|
||||
if (!data.HasMember("args"))
|
||||
{
|
||||
qDebug() << "Missing required args member";
|
||||
qCDebug(chatterinoPubsub) << "Missing required args member";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,13 +232,14 @@ PubSub::PubSub()
|
||||
|
||||
if (!args.IsArray())
|
||||
{
|
||||
qDebug() << "args member must be an array";
|
||||
qCDebug(chatterinoPubsub) << "args member must be an array";
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Size() == 0)
|
||||
{
|
||||
qDebug() << "Missing duration argument in slowmode on";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Missing duration argument in slowmode on";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,7 +247,7 @@ PubSub::PubSub()
|
||||
|
||||
if (!durationArg.IsString())
|
||||
{
|
||||
qDebug() << "Duration arg must be a string";
|
||||
qCDebug(chatterinoPubsub) << "Duration arg must be a string";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -336,7 +340,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
|
||||
action.modded = false;
|
||||
@@ -359,16 +364,18 @@ PubSub::PubSub()
|
||||
|
||||
if (!getTargetUser(data, action.target))
|
||||
{
|
||||
qDebug() << "Error parsing moderation action mod: Unable to get "
|
||||
"target_user_id";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action mod: Unable to get "
|
||||
"target_user_id";
|
||||
return;
|
||||
}
|
||||
|
||||
// Load target name from message.data.target_user_login
|
||||
if (!getTargetUserName(data, action.target))
|
||||
{
|
||||
qDebug() << "Error parsing moderation action mod: Unable to get "
|
||||
"target_user_name";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action mod: Unable to get "
|
||||
"target_user_name";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -416,7 +423,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -453,7 +461,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -484,7 +493,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -515,7 +525,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -567,7 +578,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -596,7 +608,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -625,7 +638,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -654,7 +668,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -684,7 +699,8 @@ PubSub::PubSub()
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
{
|
||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing moderation action:" << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -697,17 +713,20 @@ PubSub::PubSub()
|
||||
this->signals_.moderation.automodUserMessage.invoke(action);
|
||||
};
|
||||
|
||||
this->moderationActionHandlers["denied_automod_message"] =
|
||||
[](const auto &data, const auto &roomID) {
|
||||
// This message got denied by a moderator
|
||||
// qDebug() << QString::fromStdString(rj::stringify(data));
|
||||
};
|
||||
this->moderationActionHandlers["denied_automod_message"] = [](const auto
|
||||
&data,
|
||||
const auto
|
||||
&roomID) {
|
||||
// This message got denied by a moderator
|
||||
// qCDebug(chatterinoPubsub) << QString::fromStdString(rj::stringify(data));
|
||||
};
|
||||
|
||||
this->moderationActionHandlers["approved_automod_message"] =
|
||||
[](const auto &data, const auto &roomID) {
|
||||
// This message got approved by a moderator
|
||||
// qDebug() << QString::fromStdString(rj::stringify(data));
|
||||
};
|
||||
this->moderationActionHandlers
|
||||
["approved_automod_message"] = [](const auto &data,
|
||||
const auto &roomID) {
|
||||
// This message got approved by a moderator
|
||||
// qCDebug(chatterinoPubsub) << QString::fromStdString(rj::stringify(data));
|
||||
};
|
||||
|
||||
this->websocketClient.set_access_channels(websocketpp::log::alevel::all);
|
||||
this->websocketClient.clear_access_channels(
|
||||
@@ -737,7 +756,8 @@ void PubSub::addClient()
|
||||
|
||||
if (ec)
|
||||
{
|
||||
qDebug() << "Unable to establish connection:" << ec.message().c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Unable to establish connection:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -758,7 +778,7 @@ void PubSub::listenToWhispers(std::shared_ptr<TwitchAccount> account)
|
||||
|
||||
auto userID = account->getUserId();
|
||||
|
||||
qDebug() << "Connection open!";
|
||||
qCDebug(chatterinoPubsub) << "Connection open!";
|
||||
websocketpp::lib::error_code ec;
|
||||
|
||||
std::vector<QString> topics({topicFormat.arg(userID)});
|
||||
@@ -767,8 +787,9 @@ void PubSub::listenToWhispers(std::shared_ptr<TwitchAccount> account)
|
||||
|
||||
if (ec)
|
||||
{
|
||||
qDebug() << "Unable to send message to websocket server:"
|
||||
<< ec.message().c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Unable to send message to websocket server:"
|
||||
<< ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -799,7 +820,7 @@ void PubSub::listenToChannelModerationActions(
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Listen to topic" << topic;
|
||||
qCDebug(chatterinoPubsub) << "Listen to topic" << topic;
|
||||
|
||||
this->listenToTopic(topic, account);
|
||||
}
|
||||
@@ -818,8 +839,7 @@ void PubSub::listenToChannelPointRewards(const QString &channelID,
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Listen to topic" << topic;
|
||||
qCDebug(chatterinoPubsub) << "Listen to topic" << topic;
|
||||
|
||||
this->listenToTopic(topic, account);
|
||||
}
|
||||
@@ -884,16 +904,18 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
|
||||
|
||||
if (!res)
|
||||
{
|
||||
qDebug() << "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!msg.IsObject())
|
||||
{
|
||||
qDebug() << "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub. Root object is not an "
|
||||
"object";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub. Root object is not an "
|
||||
"object";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -901,7 +923,8 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
|
||||
|
||||
if (!rj::getSafe(msg, "type", type))
|
||||
{
|
||||
qDebug() << "Missing required string member `type` in message root";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Missing required string member `type` in message root";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -913,7 +936,8 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
|
||||
{
|
||||
if (!msg.HasMember("data"))
|
||||
{
|
||||
qDebug() << "Missing required object member `data` in message root";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Missing required object member `data` in message root";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -921,7 +945,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
|
||||
|
||||
if (!data.IsObject())
|
||||
{
|
||||
qDebug() << "Member `data` must be an object";
|
||||
qCDebug(chatterinoPubsub) << "Member `data` must be an object";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -941,7 +965,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unknown message type:" << type;
|
||||
qCDebug(chatterinoPubsub) << "Unknown message type:" << type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1002,7 +1026,8 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
qDebug() << "Exception caught in OnTLSInit:" << e.what();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Exception caught in OnTLSInit:" << e.what();
|
||||
}
|
||||
|
||||
return ctx;
|
||||
@@ -1019,12 +1044,14 @@ void PubSub::handleListenResponse(const rapidjson::Document &msg)
|
||||
|
||||
if (error.isEmpty())
|
||||
{
|
||||
qDebug() << "Successfully listened to nonce" << nonce;
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Successfully listened to nonce" << nonce;
|
||||
// Nothing went wrong
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "PubSub error:" << error << "on nonce" << nonce;
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "PubSub error:" << error << "on nonce" << nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1035,7 +1062,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (!rj::getSafe(outerData, "topic", topic))
|
||||
{
|
||||
qDebug() << "Missing required string member `topic` in outerData";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Missing required string member `topic` in outerData";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1043,7 +1071,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (!rj::getSafe(outerData, "message", payload))
|
||||
{
|
||||
qDebug() << "Expected string message in outerData";
|
||||
qCDebug(chatterinoPubsub) << "Expected string message in outerData";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1053,8 +1081,9 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (!res)
|
||||
{
|
||||
qDebug() << "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error parsing message '" << payload.c_str()
|
||||
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1064,7 +1093,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (!rj::getSafe(msg, "type", whisperType))
|
||||
{
|
||||
qDebug() << "Bad whisper data";
|
||||
qCDebug(chatterinoPubsub) << "Bad whisper data";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1082,7 +1111,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Invalid whisper type:" << whisperType.c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Invalid whisper type:" << whisperType.c_str();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1096,8 +1126,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (!rj::getSafe(data, "moderation_action", moderationAction))
|
||||
{
|
||||
qDebug() << "Missing moderation action in data:"
|
||||
<< rj::stringify(data).c_str();
|
||||
qCDebug(chatterinoPubsub) << "Missing moderation action in data:"
|
||||
<< rj::stringify(data).c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1105,8 +1135,9 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
|
||||
if (handlerIt == this->moderationActionHandlers.end())
|
||||
{
|
||||
qDebug() << "No handler found for moderation action"
|
||||
<< moderationAction.c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "No handler found for moderation action"
|
||||
<< moderationAction.c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1118,7 +1149,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
std::string pointEventType;
|
||||
if (!rj::getSafe(msg, "type", pointEventType))
|
||||
{
|
||||
qDebug() << "Bad channel point event data";
|
||||
qCDebug(chatterinoPubsub) << "Bad channel point event data";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1126,33 +1157,36 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
||||
{
|
||||
if (!rj::getSafeObject(msg, "data", msg))
|
||||
{
|
||||
qDebug() << "No data found for redeemed reward";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "No data found for redeemed reward";
|
||||
return;
|
||||
}
|
||||
if (!rj::getSafeObject(msg, "redemption", msg))
|
||||
{
|
||||
qDebug() << "No redemption info found for redeemed reward";
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "No redemption info found for redeemed reward";
|
||||
return;
|
||||
}
|
||||
this->signals_.pointReward.redeemed.invoke(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Invalid point event type:" << pointEventType.c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Invalid point event type:" << pointEventType.c_str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unknown topic:" << topic;
|
||||
qCDebug(chatterinoPubsub) << "Unknown topic:" << topic;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PubSub::runThread()
|
||||
{
|
||||
qDebug() << "Start pubsub manager thread";
|
||||
qCDebug(chatterinoPubsub) << "Start pubsub manager thread";
|
||||
this->websocketClient.run();
|
||||
qDebug() << "Done with pubsub manager thread";
|
||||
qCDebug(chatterinoPubsub) << "Done with pubsub manager thread";
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "providers/twitch/ChatterinoWebSocketppLogger.hpp"
|
||||
#include "providers/twitch/PubsubActions.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
@@ -9,6 +10,8 @@
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <websocketpp/client.hpp>
|
||||
#include <websocketpp/config/asio_client.hpp>
|
||||
#include <websocketpp/extensions/permessage_deflate/disabled.hpp>
|
||||
#include <websocketpp/logger/basic.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
@@ -21,8 +24,23 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
using WebsocketClient =
|
||||
websocketpp::client<websocketpp::config::asio_tls_client>;
|
||||
struct chatterinoconfig : public websocketpp::config::asio_tls_client {
|
||||
typedef websocketpp::log::chatterinowebsocketpplogger<
|
||||
concurrency_type, websocketpp::log::elevel>
|
||||
elog_type;
|
||||
typedef websocketpp::log::chatterinowebsocketpplogger<
|
||||
concurrency_type, websocketpp::log::alevel>
|
||||
alog_type;
|
||||
|
||||
struct permessage_deflate_config {
|
||||
};
|
||||
|
||||
typedef websocketpp::extensions::permessage_deflate::disabled<
|
||||
permessage_deflate_config>
|
||||
permessage_deflate_type;
|
||||
};
|
||||
|
||||
using WebsocketClient = websocketpp::client<chatterinoconfig>;
|
||||
using WebsocketHandle = websocketpp::connection_hdl;
|
||||
using WebsocketErrorCode = websocketpp::lib::error_code;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <memory>
|
||||
#include "common/QLogging.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -34,7 +35,8 @@ void runAfter(boost::asio::io_service &ioService, Duration duration,
|
||||
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
|
||||
if (ec)
|
||||
{
|
||||
qDebug() << "Error in runAfter:" << ec.message().c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error in runAfter:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +54,8 @@ void runAfter(std::shared_ptr<boost::asio::steady_timer> timer,
|
||||
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
|
||||
if (ec)
|
||||
{
|
||||
qDebug() << "Error in runAfter:" << ec.message().c_str();
|
||||
qCDebug(chatterinoPubsub)
|
||||
<< "Error in runAfter:" << ec.message().c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "common/Env.hpp"
|
||||
#include "common/NetworkRequest.hpp"
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
@@ -133,8 +134,9 @@ void TwitchAccount::loadIgnores()
|
||||
TwitchUser ignoredUser;
|
||||
if (!rj::getSafe(userIt->value, ignoredUser))
|
||||
{
|
||||
qDebug() << "Error parsing twitch user JSON"
|
||||
<< rj::stringify(userIt->value).c_str();
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Error parsing twitch user JSON"
|
||||
<< rj::stringify(userIt->value).c_str();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -338,14 +340,15 @@ std::set<TwitchUser> TwitchAccount::getIgnores() const
|
||||
|
||||
void TwitchAccount::loadEmotes()
|
||||
{
|
||||
qDebug() << "Loading Twitch emotes for user" << this->getUserName();
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Loading Twitch emotes for user" << this->getUserName();
|
||||
|
||||
const auto &clientID = this->getOAuthClient();
|
||||
const auto &oauthToken = this->getOAuthToken();
|
||||
|
||||
if (clientID.isEmpty() || oauthToken.isEmpty())
|
||||
{
|
||||
qDebug() << "Missing Client ID or OAuth token";
|
||||
qCDebug(chatterinoTwitch) << "Missing Client ID or OAuth token";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -356,7 +359,8 @@ void TwitchAccount::loadEmotes()
|
||||
|
||||
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
|
||||
.onError([=](NetworkResult result) {
|
||||
qDebug() << "[TwitchAccount::loadEmotes] Error" << result.status();
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "[TwitchAccount::loadEmotes] Error" << result.status();
|
||||
if (result.status() == 203)
|
||||
{
|
||||
// onFinished(FollowResult_NotFollowing);
|
||||
@@ -394,8 +398,8 @@ void TwitchAccount::autoModAllow(const QString msgID)
|
||||
|
||||
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
|
||||
.onError([=](NetworkResult result) {
|
||||
qDebug() << "[TwitchAccounts::autoModAllow] Error"
|
||||
<< result.status();
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "[TwitchAccounts::autoModAllow] Error" << result.status();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
@@ -413,8 +417,8 @@ void TwitchAccount::autoModDeny(const QString msgID)
|
||||
|
||||
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
|
||||
.onError([=](NetworkResult result) {
|
||||
qDebug() << "[TwitchAccounts::autoModDeny] Error"
|
||||
<< result.status();
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "[TwitchAccounts::autoModDeny] Error" << result.status();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
@@ -429,7 +433,8 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
|
||||
auto emoticonSets = root.FindMember("emoticon_sets");
|
||||
if (emoticonSets == root.MemberEnd() || !emoticonSets->value.IsObject())
|
||||
{
|
||||
qDebug() << "No emoticon_sets in load emotes response";
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "No emoticon_sets in load emotes response";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -445,21 +450,22 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
|
||||
{
|
||||
if (!emoteJSON.IsObject())
|
||||
{
|
||||
qDebug() << "Emote value was invalid";
|
||||
qCWarning(chatterinoTwitch) << "Emote value was invalid";
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t idNumber;
|
||||
if (!rj::getSafe(emoteJSON, "id", idNumber))
|
||||
{
|
||||
qDebug() << "No ID key found in Emote value";
|
||||
qCWarning(chatterinoTwitch) << "No ID key found in Emote value";
|
||||
return;
|
||||
}
|
||||
|
||||
QString _code;
|
||||
if (!rj::getSafe(emoteJSON, "code", _code))
|
||||
{
|
||||
qDebug() << "No code key found in Emote value";
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "No code key found in Emote value";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -486,7 +492,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
||||
{
|
||||
if (!emoteSet)
|
||||
{
|
||||
qDebug() << "null emote set sent";
|
||||
qCWarning(chatterinoTwitch) << "null emote set sent";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -502,8 +508,8 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
||||
NetworkRequest(Env::get().twitchEmoteSetResolverUrl.arg(emoteSet->key))
|
||||
.cache()
|
||||
.onError([](NetworkResult result) {
|
||||
qDebug() << "Error code" << result.status()
|
||||
<< "while loading emote set data";
|
||||
qCWarning(chatterinoTwitch) << "Error code" << result.status()
|
||||
<< "while loading emote set data";
|
||||
})
|
||||
.onSuccess([emoteSet](auto result) -> Outcome {
|
||||
auto root = result.parseRapidJson();
|
||||
@@ -525,7 +531,8 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
||||
return Failure;
|
||||
}
|
||||
|
||||
qDebug() << "Loaded twitch emote set data for" << emoteSet->key;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Loaded twitch emote set data for" << emoteSet->key;
|
||||
|
||||
auto name = channelName;
|
||||
name.detach();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "providers/twitch/TwitchAccountManager.hpp"
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
@@ -105,23 +106,26 @@ void TwitchAccountManager::reloadUsers()
|
||||
switch (this->addUser(userData))
|
||||
{
|
||||
case AddUserResponse::UserAlreadyExists: {
|
||||
qDebug() << "User" << userData.username << "already exists";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "User" << userData.username << "already exists";
|
||||
// Do nothing
|
||||
}
|
||||
break;
|
||||
case AddUserResponse::UserValuesUpdated: {
|
||||
qDebug() << "User" << userData.username
|
||||
<< "already exists, and values updated!";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "User" << userData.username
|
||||
<< "already exists, and values updated!";
|
||||
if (userData.username == this->getCurrent()->getUserName())
|
||||
{
|
||||
qDebug() << "It was the current user, so we need to "
|
||||
"reconnect stuff!";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "It was the current user, so we need to "
|
||||
"reconnect stuff!";
|
||||
this->currentUserChanged.invoke();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AddUserResponse::UserAdded: {
|
||||
qDebug() << "Added user" << userData.username;
|
||||
qCDebug(chatterinoTwitch) << "Added user" << userData.username;
|
||||
listUpdated = true;
|
||||
}
|
||||
break;
|
||||
@@ -142,14 +146,15 @@ void TwitchAccountManager::load()
|
||||
auto user = this->findUserByUsername(newUsername);
|
||||
if (user)
|
||||
{
|
||||
qDebug() << "Twitch user updated to" << newUsername;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Twitch user updated to" << newUsername;
|
||||
getHelix()->update(user->getOAuthClient(), user->getOAuthToken());
|
||||
getKraken()->update(user->getOAuthClient(), user->getOAuthToken());
|
||||
this->currentUser_ = user;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Twitch user updated to anonymous";
|
||||
qCDebug(chatterinoTwitch) << "Twitch user updated to anonymous";
|
||||
this->currentUser_ = this->anonymousUser_;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QJsonValue>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
@@ -148,7 +149,7 @@ TwitchChannel::TwitchChannel(const QString &name,
|
||||
, mod_(false)
|
||||
, titleRefreshedTime_(QTime::currentTime().addSecs(-TITLE_REFRESH_PERIOD))
|
||||
{
|
||||
qDebug() << "[TwitchChannel" << name << "] Opened";
|
||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
||||
|
||||
this->liveStatusChanged.connect([this]() {
|
||||
if (this->isLive() == 1)
|
||||
@@ -305,8 +306,8 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[TwitchChannel" << this->getName()
|
||||
<< "] Send message:" << message;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "[TwitchChannel" << this->getName() << "] Send message:" << message;
|
||||
|
||||
// Do last message processing
|
||||
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
|
||||
@@ -334,7 +335,7 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||
|
||||
if (messageSent)
|
||||
{
|
||||
qDebug() << "sent";
|
||||
qCDebug(chatterinoTwitch) << "sent";
|
||||
this->lastSentMessage_ = parsedMessage;
|
||||
}
|
||||
}
|
||||
@@ -593,8 +594,8 @@ void TwitchChannel::refreshLiveStatus()
|
||||
|
||||
if (roomID.isEmpty())
|
||||
{
|
||||
qDebug() << "[TwitchChannel" << this->getName()
|
||||
<< "] Refreshing live status (Missing ID)";
|
||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << this->getName()
|
||||
<< "] Refreshing live status (Missing ID)";
|
||||
this->setLive(false);
|
||||
return;
|
||||
}
|
||||
@@ -908,7 +909,8 @@ boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||
int bitAmount = amount.toInt(&ok);
|
||||
if (!ok)
|
||||
{
|
||||
qDebug() << "Error parsing bit amount in cheerEmote";
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Error parsing bit amount in cheerEmote";
|
||||
}
|
||||
for (const auto &emote : set.cheerEmotes)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "providers/twitch/TwitchHelpers.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -6,7 +7,7 @@ bool trimChannelName(const QString &channelName, QString &outChannelName)
|
||||
{
|
||||
if (channelName.length() < 2)
|
||||
{
|
||||
qDebug() << "channel name length below 2";
|
||||
qCDebug(chatterinoTwitch) << "channel name length below 2";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Application.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "common/Env.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
@@ -55,7 +56,7 @@ void TwitchIrcServer::initializeConnection(IrcConnection *connection,
|
||||
std::shared_ptr<TwitchAccount> account =
|
||||
getApp()->accounts->twitch.getCurrent();
|
||||
|
||||
qDebug() << "logging in as" << account->getUserName();
|
||||
qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName();
|
||||
|
||||
QString username = account->getUserName();
|
||||
QString oauthToken = account->getOAuthToken();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QMediaPlayer>
|
||||
#include <QStringRef>
|
||||
#include <boost/variant.hpp>
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -712,7 +713,8 @@ void TwitchMessageBuilder::runIgnoreReplaces(
|
||||
{
|
||||
if ((*copy).ptr == nullptr)
|
||||
{
|
||||
qDebug() << "remem nullptr" << (*copy).name.string;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "remem nullptr" << (*copy).name.string;
|
||||
}
|
||||
}
|
||||
std::vector<TwitchEmoteOccurence> v(it, twitchEmotes.end());
|
||||
@@ -749,7 +751,8 @@ void TwitchMessageBuilder::runIgnoreReplaces(
|
||||
{
|
||||
if (emote.second == nullptr)
|
||||
{
|
||||
qDebug() << "emote null" << emote.first.string;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "emote null" << emote.first.string;
|
||||
}
|
||||
twitchEmotes.push_back(TwitchEmoteOccurence{
|
||||
startIndex + pos,
|
||||
@@ -821,7 +824,8 @@ void TwitchMessageBuilder::runIgnoreReplaces(
|
||||
{
|
||||
if (tup.ptr == nullptr)
|
||||
{
|
||||
qDebug() << "v nullptr" << tup.name.string;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "v nullptr" << tup.name.string;
|
||||
continue;
|
||||
}
|
||||
QRegularExpression emoteregex(
|
||||
@@ -885,7 +889,8 @@ void TwitchMessageBuilder::runIgnoreReplaces(
|
||||
{
|
||||
if (tup.ptr == nullptr)
|
||||
{
|
||||
qDebug() << "v nullptr" << tup.name.string;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "v nullptr" << tup.name.string;
|
||||
continue;
|
||||
}
|
||||
QRegularExpression emoteregex(
|
||||
@@ -955,7 +960,8 @@ void TwitchMessageBuilder::appendTwitchEmote(
|
||||
start, end, app->emotes->twitch.getOrCreateEmote(id, name), name};
|
||||
if (emoteOccurence.ptr == nullptr)
|
||||
{
|
||||
qDebug() << "nullptr" << emoteOccurence.name.string;
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "nullptr" << emoteOccurence.name.string;
|
||||
}
|
||||
vec.push_back(std::move(emoteOccurence));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -320,14 +321,14 @@ NetworkRequest Helix::makeRequest(QString url, QUrlQuery urlQuery)
|
||||
|
||||
if (this->clientId.isEmpty())
|
||||
{
|
||||
qDebug()
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Helix::makeRequest called without a client ID set BabyRage";
|
||||
// return boost::none;
|
||||
}
|
||||
|
||||
if (this->oauthToken.isEmpty())
|
||||
{
|
||||
qDebug()
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Helix::makeRequest called without an oauth token set BabyRage";
|
||||
// return boost::none;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "providers/twitch/api/Kraken.hpp"
|
||||
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -54,7 +55,7 @@ NetworkRequest Kraken::makeRequest(QString url, QUrlQuery urlQuery)
|
||||
|
||||
if (this->clientId.isEmpty())
|
||||
{
|
||||
qDebug()
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Kraken::makeRequest called without a client ID set BabyRage";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user