mirror-chatterino2/src/providers/twitch/twitchchannel.hpp

139 lines
3.3 KiB
C++
Raw Normal View History

#pragma once
2018-02-05 15:11:50 +01:00
#include <IrcConnection>
#include "channel.hpp"
2018-02-05 15:11:50 +01:00
#include "common.hpp"
2017-12-31 00:50:07 +01:00
#include "singletons/emotemanager.hpp"
#include "singletons/ircmanager.hpp"
2017-12-31 22:58:35 +01:00
#include "util/concurrentmap.hpp"
2018-05-28 08:34:54 +02:00
#include "util/mutexvalue.hpp"
#include <pajlada/signals/signalholder.hpp>
#include <mutex>
namespace chatterino {
2018-02-05 15:11:50 +01:00
namespace providers {
namespace twitch {
2018-02-05 15:11:50 +01:00
class TwitchServer;
class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder
{
QTimer *liveStatusTimer;
QTimer *chattersListTimer;
public:
struct StreamStatus {
bool live = false;
bool rerun = false;
unsigned viewerCount = 0;
QString title;
QString game;
QString uptime;
QString streamType;
};
struct UserState {
bool mod;
bool broadcaster;
};
2018-05-24 08:58:34 +02:00
struct RoomModes {
bool submode = false;
bool r9k = false;
bool emoteOnly = false;
// int folowerOnly = 0;
int slowMode = 0;
QString broadcasterLang;
};
2018-03-30 12:37:00 +02:00
~TwitchChannel() final;
void reloadChannelEmotes();
bool isEmpty() const override;
bool canSendMessage() const override;
void sendMessage(const QString &message) override;
bool isMod() const override;
2018-01-17 18:36:12 +01:00
void setMod(bool value);
bool isBroadcaster() const override;
2018-01-17 17:17:26 +01:00
bool hasModRights();
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
void addJoinedUser(const QString &user);
void addPartedUser(const QString &user);
2017-12-31 22:58:35 +01:00
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
const QString subscriptionURL;
const QString channelURL;
const QString popoutPlayerURL;
void setRoomID(const QString &_roomID);
pajlada::Signals::NoArgSignal roomIDchanged;
pajlada::Signals::NoArgSignal updateLiveInfo;
pajlada::Signals::NoArgBoltSignal fetchMessages;
pajlada::Signals::NoArgSignal userStateChanged;
2018-05-24 08:58:34 +02:00
pajlada::Signals::NoArgSignal roomModesChanged;
QString roomID;
2018-05-25 13:53:55 +02:00
2018-05-24 08:58:34 +02:00
RoomModes getRoomModes();
void setRoomModes(const RoomModes &roomModes);
2018-05-24 08:58:34 +02:00
StreamStatus getStreamStatus() const;
struct NameOptions {
QString displayName;
QString localizedName;
};
2018-05-24 08:58:34 +02:00
bool isLive() const;
private:
2018-02-05 15:11:50 +01:00
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
void setLive(bool newLiveStatus);
void refreshLiveStatus();
void startRefreshLiveStatusTimer(int intervalMS);
mutable std::mutex streamStatusMutex;
StreamStatus streamStatus;
mutable std::mutex userStateMutex;
UserState userState;
void fetchRecentMessages();
2018-01-17 17:17:26 +01:00
bool mod;
QByteArray messageSuffix;
QString lastSentMessage;
2018-05-24 08:58:34 +02:00
RoomModes roomModes;
std::mutex roomModeMutex;
QObject object;
std::mutex joinedUserMutex;
QStringList joinedUsers;
bool joinedUsersMergeQueued = false;
std::mutex partedUserMutex;
QStringList partedUsers;
bool partedUsersMergeQueued = false;
Communi::IrcConnection *readConnection;
2018-02-05 15:11:50 +01:00
friend class TwitchServer;
// Key = login name
std::map<QString, NameOptions> recentChatters;
std::mutex recentChattersMutex;
2018-02-05 15:11:50 +01:00
};
} // namespace twitch
2018-02-05 15:11:50 +01:00
} // namespace providers
} // namespace chatterino