2018-02-05 15:11:50 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "providers/irc/abstractircserver.hpp"
|
|
|
|
#include "providers/twitch/twitchaccount.hpp"
|
|
|
|
#include "providers/twitch/twitchchannel.hpp"
|
2018-05-28 08:34:54 +02:00
|
|
|
#include "util/mutexvalue.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 {
|
|
|
|
namespace providers {
|
|
|
|
namespace twitch {
|
2018-03-25 11:37:57 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
class TwitchServer final : public irc::AbstractIrcServer
|
|
|
|
{
|
2018-04-30 20:35:01 +02:00
|
|
|
public:
|
2018-02-05 15:11:50 +01:00
|
|
|
TwitchServer();
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
void initialize();
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-02-05 21:20:38 +01:00
|
|
|
// fourtf: ugh
|
|
|
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
|
|
|
|
2018-04-22 15:36:01 +02:00
|
|
|
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
|
|
|
|
|
2018-05-25 13:53:55 +02:00
|
|
|
util::MutexValue<QString> lastUserThatWhisperedMe;
|
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
2018-06-04 21:05:18 +02:00
|
|
|
void initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
|
2018-04-01 16:43:30 +02:00
|
|
|
bool isWrite) override;
|
|
|
|
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-04-01 16:43:30 +02:00
|
|
|
void privateMessageReceived(Communi::IrcPrivateMessage *message) override;
|
|
|
|
void messageReceived(Communi::IrcMessage *message) override;
|
|
|
|
void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
|
2018-02-05 15:11:50 +01:00
|
|
|
|
2018-04-01 16:43:30 +02:00
|
|
|
std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
|
2018-04-01 15:10:15 +02:00
|
|
|
|
2018-04-21 00:40:17 +02:00
|
|
|
QString cleanChannelName(const QString &dirtyChannelName) override;
|
2018-05-25 13:53:55 +02:00
|
|
|
|
|
|
|
private:
|
2018-06-06 18:57:22 +02:00
|
|
|
std::mutex lastMessageMutex;
|
2018-06-24 12:59:47 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent);
|
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 twitch
|
|
|
|
} // namespace providers
|
|
|
|
} // namespace chatterino
|