#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 "providers/twitch/TwitchBadges.hpp" #include #include #include namespace chatterino { class Settings; class Paths; class PubSub; class TwitchChannel; class TwitchServer final : public AbstractIrcServer, public Singleton { public: TwitchServer(); virtual ~TwitchServer() override = default; virtual void initialize(Settings &settings, Paths &paths) override; void forEachChannelAndSpecialChannels(std::function func); std::shared_ptr getChannelOrEmptyByID(const QString &channelID); Atomic lastUserThatWhisperedMe; const ChannelPtr whispersChannel; const ChannelPtr mentionsChannel; IndirectChannel watchingChannel; PubSub *pubsub; protected: virtual void initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) override; virtual std::shared_ptr createChannel( const QString &channelName) override; virtual void privateMessageReceived( Communi::IrcPrivateMessage *message) override; virtual void messageReceived(Communi::IrcMessage *message) override; virtual void writeConnectionMessageReceived( Communi::IrcMessage *message) override; virtual std::shared_ptr 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); std::mutex lastMessageMutex_; std::queue lastMessagePleb_; std::queue lastMessageMod_; std::chrono::steady_clock::time_point lastErrorTimeSpeed_; std::chrono::steady_clock::time_point lastErrorTimeAmount_; bool singleConnection_ = false; TwitchBadges twitchBadges; BttvEmotes bttv; FfzEmotes ffz; pajlada::Signals::SignalHolder signalHolder_; }; } // namespace chatterino