added roommodes to the splitheader
This commit is contained in:
@@ -27,34 +27,48 @@ IrcMessageHandler &IrcMessageHandler::getInstance()
|
||||
void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
const auto &tags = message->tags();
|
||||
auto iterator = tags.find("room-id");
|
||||
auto app = getApp();
|
||||
|
||||
if (iterator != tags.end()) {
|
||||
auto roomID = iterator.value().toString();
|
||||
// get twitch channel
|
||||
QString chanName;
|
||||
if (!trimChannelName(message->parameter(0), chanName)) {
|
||||
return;
|
||||
}
|
||||
auto chan = app->twitch.server->getChannelOrEmpty(chanName);
|
||||
TwitchChannel *twitchChannel = dynamic_cast<twitch::TwitchChannel *>(chan.get());
|
||||
|
||||
QStringList words = QString(message->toData()).split("#");
|
||||
if (twitchChannel) {
|
||||
// room-id
|
||||
decltype(tags.find("xD")) it;
|
||||
|
||||
// ensure the format is valid
|
||||
if (words.length() < 2) {
|
||||
return;
|
||||
}
|
||||
if ((it = tags.find("room-id")) != tags.end()) {
|
||||
auto roomID = it.value().toString();
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
QString channelName = words.at(1);
|
||||
|
||||
auto channel = app->twitch.server->getChannelOrEmpty(channelName);
|
||||
|
||||
if (channel->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto twitchChannel = dynamic_cast<twitch::TwitchChannel *>(channel.get())) {
|
||||
// set the room id of the channel
|
||||
twitchChannel->setRoomID(roomID);
|
||||
|
||||
app->resources->loadChannelData(roomID);
|
||||
}
|
||||
|
||||
app->resources->loadChannelData(roomID);
|
||||
// Room modes
|
||||
TwitchChannel::RoomModes roomModes = twitchChannel->getRoomModes();
|
||||
|
||||
if ((it = tags.find("emote-only")) != tags.end()) {
|
||||
roomModes.emoteOnly = it.value() == "1";
|
||||
}
|
||||
if ((it = tags.find("subs-only")) != tags.end()) {
|
||||
roomModes.submode = it.value() == "1";
|
||||
}
|
||||
if ((it = tags.find("slow")) != tags.end()) {
|
||||
roomModes.slowMode = it.value().toInt();
|
||||
}
|
||||
if ((it = tags.find("r9k")) != tags.end()) {
|
||||
roomModes.r9k = it.value() == "1";
|
||||
}
|
||||
if ((it = tags.find("broadcaster-lang")) != tags.end()) {
|
||||
roomModes.broadcasterLang = it.value().toString();
|
||||
}
|
||||
|
||||
twitchChannel->setRoomModes(roomModes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +80,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
|
||||
QString chanName;
|
||||
if (!TrimChannelName(message->parameter(0), chanName)) {
|
||||
if (!trimChannelName(message->parameter(0), chanName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +130,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||
auto app = getApp();
|
||||
|
||||
QString channelName;
|
||||
if (!TrimChannelName(message->parameter(0), channelName)) {
|
||||
if (!trimChannelName(message->parameter(0), channelName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +217,8 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
// auto channel = app->twitch.server->getChannelOrEmpty(channelName);
|
||||
|
||||
// if (channel->isEmpty()) {
|
||||
// debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager",
|
||||
// debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel
|
||||
// manager",
|
||||
// channelName);
|
||||
// return;
|
||||
// }
|
||||
|
||||
@@ -86,7 +86,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||
};
|
||||
|
||||
auto doRefreshChatters = [=]() {
|
||||
const auto streamStatus = this->GetStreamStatus();
|
||||
const auto streamStatus = this->getStreamStatus();
|
||||
|
||||
if (app->settings->onlyFetchChattersForSmallerStreamers) {
|
||||
if (streamStatus.live && streamStatus.viewerCount > app->settings->smallStreamerLimit) {
|
||||
@@ -213,6 +213,35 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr<messages::Message> &m
|
||||
this->completionModel.addUser(message->displayName);
|
||||
}
|
||||
|
||||
TwitchChannel::RoomModes TwitchChannel::getRoomModes()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
|
||||
return this->roomModes;
|
||||
}
|
||||
|
||||
void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
this->roomModes = _roomModes;
|
||||
}
|
||||
|
||||
this->roomModesChanged.invoke();
|
||||
}
|
||||
|
||||
bool TwitchChannel::isLive() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus.live;
|
||||
}
|
||||
|
||||
TwitchChannel::StreamStatus TwitchChannel::getStreamStatus() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus;
|
||||
}
|
||||
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
bool gotNewLiveStatus = false;
|
||||
|
||||
@@ -38,6 +38,15 @@ public:
|
||||
bool broadcaster;
|
||||
};
|
||||
|
||||
struct RoomModes {
|
||||
bool submode = false;
|
||||
bool r9k = false;
|
||||
bool emoteOnly = false;
|
||||
// int folowerOnly = 0;
|
||||
int slowMode = 0;
|
||||
QString broadcasterLang;
|
||||
};
|
||||
|
||||
~TwitchChannel() final;
|
||||
|
||||
void reloadChannelEmotes();
|
||||
@@ -66,25 +75,20 @@ public:
|
||||
|
||||
pajlada::Signals::NoArgBoltSignal fetchMessages;
|
||||
pajlada::Signals::NoArgSignal userStateChanged;
|
||||
pajlada::Signals::NoArgSignal roomModesChanged;
|
||||
|
||||
QString roomID;
|
||||
RoomModes getRoomModes();
|
||||
void setRoomModes(const RoomModes &roomModes);
|
||||
|
||||
StreamStatus GetStreamStatus() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus;
|
||||
}
|
||||
StreamStatus getStreamStatus() const;
|
||||
|
||||
struct NameOptions {
|
||||
QString displayName;
|
||||
QString localizedName;
|
||||
};
|
||||
|
||||
bool IsLive() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus.live;
|
||||
}
|
||||
bool isLive() const;
|
||||
|
||||
private:
|
||||
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
|
||||
@@ -103,6 +107,8 @@ private:
|
||||
bool mod;
|
||||
QByteArray messageSuffix;
|
||||
QString lastSentMessage;
|
||||
RoomModes roomModes;
|
||||
std::mutex roomModeMutex;
|
||||
|
||||
Communi::IrcConnection *readConnection;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace chatterino {
|
||||
namespace providers {
|
||||
namespace twitch {
|
||||
|
||||
bool TrimChannelName(const QString &channelName, QString &outChannelName)
|
||||
bool trimChannelName(const QString &channelName, QString &outChannelName)
|
||||
{
|
||||
if (channelName.length() < 3) {
|
||||
debug::Log("channel name length below 3");
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace chatterino {
|
||||
namespace providers {
|
||||
namespace twitch {
|
||||
|
||||
bool TrimChannelName(const QString &channelName, QString &outChannelName);
|
||||
bool trimChannelName(const QString &channelName, QString &outChannelName);
|
||||
|
||||
} // namespace twitch
|
||||
} // namespace providers
|
||||
|
||||
@@ -78,7 +78,7 @@ std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
|
||||
void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
||||
{
|
||||
QString channelName;
|
||||
if (!TrimChannelName(message->target(), channelName)) {
|
||||
if (!trimChannelName(message->target(), channelName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user