2017-09-16 00:05:06 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
#include <IrcConnection>
|
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
#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-25 13:53:55 +02:00
|
|
|
#include "util/mutexvalue.h"
|
2017-09-16 00:05:06 +02:00
|
|
|
|
2018-04-15 15:09:31 +02:00
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
|
|
|
|
2018-03-30 15:05:33 +02:00
|
|
|
#include <mutex>
|
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
namespace chatterino {
|
2018-02-05 15:11:50 +01:00
|
|
|
namespace providers {
|
2017-09-16 00:05:06 +02:00
|
|
|
namespace twitch {
|
2018-03-24 12:02:07 +01:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
class TwitchServer;
|
2018-03-24 12:02:07 +01:00
|
|
|
|
2018-04-15 15:09:31 +02:00
|
|
|
class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder
|
2017-09-16 00:05:06 +02:00
|
|
|
{
|
2017-11-04 14:57:29 +01:00
|
|
|
QTimer *liveStatusTimer;
|
2018-03-24 12:02:07 +01:00
|
|
|
QTimer *chattersListTimer;
|
2017-11-04 14:57:29 +01:00
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
public:
|
2018-03-30 15:05:33 +02:00
|
|
|
struct StreamStatus {
|
|
|
|
bool live = false;
|
2018-04-08 15:14:14 +02:00
|
|
|
bool rerun = false;
|
2018-03-30 15:05:33 +02:00
|
|
|
unsigned viewerCount = 0;
|
|
|
|
QString title;
|
|
|
|
QString game;
|
|
|
|
QString uptime;
|
|
|
|
};
|
|
|
|
|
2018-04-15 15:09:31 +02:00
|
|
|
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;
|
2017-09-16 00:05:06 +02:00
|
|
|
|
|
|
|
void reloadChannelEmotes();
|
|
|
|
|
|
|
|
bool isEmpty() const override;
|
|
|
|
bool canSendMessage() const override;
|
|
|
|
void sendMessage(const QString &message) override;
|
|
|
|
|
2018-01-18 18:17:48 +01:00
|
|
|
bool isMod() const override;
|
2018-01-17 18:36:12 +01:00
|
|
|
void setMod(bool value);
|
2018-01-17 17:17:26 +01:00
|
|
|
bool isBroadcaster();
|
|
|
|
bool hasModRights();
|
|
|
|
|
2018-03-30 12:16:12 +02:00
|
|
|
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
|
|
|
|
2017-12-31 22:58:35 +01:00
|
|
|
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
|
|
|
|
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
|
2017-12-23 23:24:35 +01:00
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
const QString subscriptionURL;
|
|
|
|
const QString channelURL;
|
|
|
|
const QString popoutPlayerURL;
|
2017-09-16 00:05:06 +02:00
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
void setRoomID(const QString &_roomID);
|
2018-04-03 02:55:32 +02:00
|
|
|
pajlada::Signals::NoArgSignal roomIDchanged;
|
2018-04-08 14:45:47 +02:00
|
|
|
pajlada::Signals::NoArgSignal updateLiveInfo;
|
2017-09-16 00:05:06 +02:00
|
|
|
|
2017-12-28 00:03:52 +01:00
|
|
|
pajlada::Signals::NoArgBoltSignal fetchMessages;
|
2018-04-03 02:55:32 +02:00
|
|
|
pajlada::Signals::NoArgSignal userStateChanged;
|
2018-05-24 08:58:34 +02:00
|
|
|
pajlada::Signals::NoArgSignal roomModesChanged;
|
2017-12-28 00:03:52 +01:00
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
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-03-30 15:05:33 +02:00
|
|
|
|
2018-05-24 08:58:34 +02:00
|
|
|
StreamStatus getStreamStatus() const;
|
2017-09-16 00:05:06 +02:00
|
|
|
|
2018-03-30 12:16:12 +02:00
|
|
|
struct NameOptions {
|
|
|
|
QString displayName;
|
|
|
|
QString localizedName;
|
|
|
|
};
|
|
|
|
|
2018-05-24 08:58:34 +02:00
|
|
|
bool isLive() const;
|
2018-03-30 15:05:33 +02:00
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
private:
|
2018-02-05 15:11:50 +01:00
|
|
|
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
|
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
void setLive(bool newLiveStatus);
|
|
|
|
void refreshLiveStatus();
|
|
|
|
|
2018-03-30 15:05:33 +02:00
|
|
|
mutable std::mutex streamStatusMutex;
|
|
|
|
StreamStatus streamStatus;
|
|
|
|
|
2018-04-15 15:09:31 +02:00
|
|
|
mutable std::mutex userStateMutex;
|
|
|
|
UserState userState;
|
|
|
|
|
2017-12-28 00:03:52 +01:00
|
|
|
void fetchRecentMessages();
|
2018-01-17 17:17:26 +01:00
|
|
|
|
|
|
|
bool mod;
|
2018-01-22 15:24:39 +01:00
|
|
|
QByteArray messageSuffix;
|
|
|
|
QString lastSentMessage;
|
2018-05-24 08:58:34 +02:00
|
|
|
RoomModes roomModes;
|
|
|
|
std::mutex roomModeMutex;
|
2017-11-04 14:57:29 +01:00
|
|
|
|
2018-03-31 13:44:15 +02:00
|
|
|
Communi::IrcConnection *readConnection;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
|
|
|
friend class TwitchServer;
|
2018-03-30 12:16:12 +02:00
|
|
|
|
|
|
|
// Key = login name
|
|
|
|
std::map<QString, NameOptions> recentChatters;
|
|
|
|
std::mutex recentChattersMutex;
|
2018-02-05 15:11:50 +01:00
|
|
|
};
|
2018-03-24 12:02:07 +01:00
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
} // namespace twitch
|
2018-02-05 15:11:50 +01:00
|
|
|
} // namespace providers
|
2017-11-04 14:57:29 +01:00
|
|
|
} // namespace chatterino
|