mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
7e13564c24
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
81 lines
2.4 KiB
C++
81 lines
2.4 KiB
C++
#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;
|
|
|
|
class TwitchIrcServer final : public AbstractIrcServer, public Singleton
|
|
{
|
|
public:
|
|
TwitchIrcServer();
|
|
virtual ~TwitchIrcServer() override = default;
|
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
|
|
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
|
|
|
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
|
|
|
|
Atomic<QString> lastUserThatWhisperedMe;
|
|
|
|
const ChannelPtr whispersChannel;
|
|
const ChannelPtr mentionsChannel;
|
|
const ChannelPtr liveChannel;
|
|
IndirectChannel watchingChannel;
|
|
|
|
PubSub *pubsub;
|
|
|
|
const BttvEmotes &getBttvEmotes() const;
|
|
const FfzEmotes &getFfzEmotes() const;
|
|
|
|
protected:
|
|
virtual void initializeConnection(IrcConnection *connection,
|
|
ConnectionType type) override;
|
|
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);
|
|
|
|
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;
|
|
|
|
pajlada::Signals::SignalHolder signalHolder_;
|
|
};
|
|
|
|
} // namespace chatterino
|