2019-09-08 22:27:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/Atomic.hpp"
|
|
|
|
#include "common/Channel.hpp"
|
|
|
|
#include "common/Singleton.hpp"
|
|
|
|
#include "pajlada/signals/signalholder.hpp"
|
|
|
|
#include "providers/bttv/BttvEmotes.hpp"
|
|
|
|
#include "providers/ffz/FfzEmotes.hpp"
|
|
|
|
#include "providers/irc/AbstractIrcServer.hpp"
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <memory>
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
class Settings;
|
|
|
|
class Paths;
|
|
|
|
class PubSub;
|
|
|
|
class TwitchChannel;
|
|
|
|
|
2019-09-18 13:03:16 +02:00
|
|
|
class TwitchIrcServer final : public AbstractIrcServer, public Singleton
|
2019-09-08 22:27:57 +02:00
|
|
|
{
|
|
|
|
public:
|
2019-09-18 13:03:16 +02:00
|
|
|
TwitchIrcServer();
|
|
|
|
virtual ~TwitchIrcServer() override = default;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
|
|
|
|
|
|
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
|
|
|
|
|
2022-05-22 17:51:23 +02:00
|
|
|
void bulkRefreshLiveStatus();
|
|
|
|
|
2019-09-08 22:27:57 +02:00
|
|
|
Atomic<QString> lastUserThatWhisperedMe;
|
|
|
|
|
|
|
|
const ChannelPtr whispersChannel;
|
|
|
|
const ChannelPtr mentionsChannel;
|
2021-05-09 16:17:04 +02:00
|
|
|
const ChannelPtr liveChannel;
|
2019-09-08 22:27:57 +02:00
|
|
|
IndirectChannel watchingChannel;
|
|
|
|
|
|
|
|
PubSub *pubsub;
|
|
|
|
|
|
|
|
const BttvEmotes &getBttvEmotes() const;
|
|
|
|
const FfzEmotes &getFfzEmotes() const;
|
|
|
|
|
|
|
|
protected:
|
2019-09-18 13:03:16 +02:00
|
|
|
virtual void initializeConnection(IrcConnection *connection,
|
|
|
|
ConnectionType type) override;
|
2019-09-08 22:27:57 +02:00
|
|
|
virtual std::shared_ptr<Channel> createChannel(
|
|
|
|
const QString &channelName) override;
|
|
|
|
|
|
|
|
virtual void privateMessageReceived(
|
|
|
|
Communi::IrcPrivateMessage *message) override;
|
|
|
|
virtual void readConnectionMessageReceived(
|
|
|
|
Communi::IrcMessage *message) override;
|
|
|
|
virtual void writeConnectionMessageReceived(
|
|
|
|
Communi::IrcMessage *message) override;
|
|
|
|
|
|
|
|
virtual std::shared_ptr<Channel> getCustomChannel(
|
|
|
|
const QString &channelname) override;
|
|
|
|
|
|
|
|
virtual QString cleanChannelName(const QString &dirtyChannelName) override;
|
|
|
|
virtual bool hasSeparateWriteConnection() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onMessageSendRequested(TwitchChannel *channel, const QString &message,
|
|
|
|
bool &sent);
|
2022-07-31 12:45:25 +02:00
|
|
|
void onReplySendRequested(TwitchChannel *channel, const QString &message,
|
|
|
|
const QString &replyId, bool &sent);
|
|
|
|
|
|
|
|
bool prepareToSend(TwitchChannel *channel);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
std::mutex lastMessageMutex_;
|
|
|
|
std::queue<std::chrono::steady_clock::time_point> lastMessagePleb_;
|
|
|
|
std::queue<std::chrono::steady_clock::time_point> lastMessageMod_;
|
|
|
|
std::chrono::steady_clock::time_point lastErrorTimeSpeed_;
|
|
|
|
std::chrono::steady_clock::time_point lastErrorTimeAmount_;
|
|
|
|
|
|
|
|
BttvEmotes bttv;
|
|
|
|
FfzEmotes ffz;
|
2022-05-22 17:51:23 +02:00
|
|
|
QTimer bulkLiveStatusTimer_;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
pajlada::Signals::SignalHolder signalHolder_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|