2018-02-05 15:11:50 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-11 14:20:53 +02:00
|
|
|
#include "common/Atomic.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "common/Channel.hpp"
|
2018-07-07 11:41:01 +02:00
|
|
|
#include "common/Singleton.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "pajlada/signals/signalholder.hpp"
|
2018-08-12 00:01:37 +02:00
|
|
|
#include "providers/bttv/BttvEmotes.hpp"
|
|
|
|
#include "providers/ffz/FfzEmotes.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "providers/irc/AbstractIrcServer.hpp"
|
2018-08-14 17:45:17 +02:00
|
|
|
#include "providers/twitch/TwitchBadges.hpp"
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-06-24 12:59:47 +02:00
|
|
|
#include <chrono>
|
2018-04-15 15:09:31 +02:00
|
|
|
#include <memory>
|
2018-06-06 18:57:22 +02:00
|
|
|
#include <queue>
|
2018-04-15 15:09:31 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
namespace chatterino {
|
2018-03-25 11:37:57 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
class Settings;
|
|
|
|
class Paths;
|
2018-07-07 11:41:01 +02:00
|
|
|
class PubSub;
|
2018-08-13 14:38:03 +02:00
|
|
|
class TwitchChannel;
|
2018-07-07 11:41:01 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
class TwitchServer final : public AbstractIrcServer, public Singleton
|
2018-02-05 15:11:50 +01:00
|
|
|
{
|
2018-04-30 20:35:01 +02:00
|
|
|
public:
|
2018-02-05 15:11:50 +01:00
|
|
|
TwitchServer();
|
2018-07-07 11:41:01 +02:00
|
|
|
virtual ~TwitchServer() override = default;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-02-05 21:20:38 +01:00
|
|
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
|
|
|
|
2018-04-22 15:36:01 +02:00
|
|
|
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
|
|
|
|
|
2018-08-11 14:20:53 +02:00
|
|
|
Atomic<QString> lastUserThatWhisperedMe;
|
2018-05-25 13:53:55 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
const ChannelPtr whispersChannel;
|
|
|
|
const ChannelPtr mentionsChannel;
|
2018-04-20 19:54:45 +02:00
|
|
|
IndirectChannel watchingChannel;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-07-07 11:41:01 +02:00
|
|
|
PubSub *pubsub;
|
|
|
|
|
2018-10-25 21:51:55 +02:00
|
|
|
const BttvEmotes &getBttvEmotes() const;
|
|
|
|
const FfzEmotes &getFfzEmotes() const;
|
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
protected:
|
2018-07-16 17:23:41 +02:00
|
|
|
virtual void initializeConnection(IrcConnection *connection, bool isRead,
|
|
|
|
bool isWrite) override;
|
2018-08-06 21:17:03 +02:00
|
|
|
virtual std::shared_ptr<Channel> createChannel(
|
|
|
|
const QString &channelName) override;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
virtual void privateMessageReceived(
|
|
|
|
Communi::IrcPrivateMessage *message) override;
|
2018-07-16 17:23:41 +02:00
|
|
|
virtual void messageReceived(Communi::IrcMessage *message) override;
|
2018-08-06 21:17:03 +02:00
|
|
|
virtual void writeConnectionMessageReceived(
|
|
|
|
Communi::IrcMessage *message) override;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2019-08-22 22:04:02 +02:00
|
|
|
virtual void onConnected(IrcConnection *connection) override;
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
virtual std::shared_ptr<Channel> getCustomChannel(
|
|
|
|
const QString &channelname) override;
|
2018-04-01 15:10:15 +02:00
|
|
|
|
2018-07-16 17:23:41 +02:00
|
|
|
virtual QString cleanChannelName(const QString &dirtyChannelName) override;
|
|
|
|
virtual bool hasSeparateWriteConnection() const override;
|
2018-05-25 13:53:55 +02:00
|
|
|
|
|
|
|
private:
|
2018-08-06 21:17:03 +02:00
|
|
|
void onMessageSendRequested(TwitchChannel *channel, const QString &message,
|
|
|
|
bool &sent);
|
2018-07-06 19:23:47 +02:00
|
|
|
|
2018-06-24 13:06:11 +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_;
|
2018-07-16 17:23:41 +02:00
|
|
|
|
|
|
|
bool singleConnection_ = false;
|
2018-08-14 17:45:17 +02:00
|
|
|
TwitchBadges twitchBadges;
|
2018-08-12 00:01:37 +02:00
|
|
|
BttvEmotes bttv;
|
|
|
|
FfzEmotes ffz;
|
2018-07-16 17:23:41 +02:00
|
|
|
|
|
|
|
pajlada::Signals::SignalHolder signalHolder_;
|
2018-02-05 15:11:50 +01:00
|
|
|
};
|
2018-03-25 11:37:57 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
} // namespace chatterino
|