/* This file is part of IRCaBot. IRCaBot is IRC logger with features. Source code: https://notabug.org/acetone/ircabot. Copyright (C) acetone, 2023. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include "config.h" #include "libirc/irc.h" #include "voicedlist.h" #include #include #include class IRCNetworkClient : public QObject { friend IRCNetworkClientStarter; Q_OBJECT public: IRCNetworkClient(QObject* parent = nullptr); void setConfig(QSharedPointer config); // after config change; voiceGate have effect in run-time automatically uint reloadChannelList(); void addNicknameToVoicedGroup(const QString& nickname); const QSharedPointer network() { return m_network; } signals: void Event_NewDirectMessage(QString sender, QString text); void Event_NewChannelMessage(QString channel, QString sender, QString text); void stopped(); void doStopPrivate(); public slots: void start(); void stop(); private slots: void Slot_privMsg(libircclient::Parser* p); void Slot_adminIdentified(libircclient::Parser* p); void Slot_onDirectMessage(QString sender, QString text); void Slot_onChannelMessage(QString channel, QString sender, QString text); void Slot_onJoin(libircclient::Parser*, libircclient::User* u, libircclient::Channel* c); void Slot_onMode(libircclient::Parser* p); void Slot_onWelcome(); void Slot_onDisconnected(); void stopPrivate(); private: void processAdminCommand(const QString& text); void processVoiceRequest(const QString& sender); void sendVoiceGateInvite(const QString& nickname); QList getChannelsWhereIAmHavePrivileges(); void giveTheVoiceFlag(const QStringList& nicknames, const QString& channel = ""); void giveTheVoiceFlagIfItsWillBeOkOrSendInvite(const QString& nickname, libircclient::Channel* channel); QSharedPointer m_config = nullptr; QSharedPointer m_network = nullptr; QString m_adminCommandBuffer; QMap m_voiceGateRequestsTimestamp; // nickname QMap m_voiceGateInviteSendedTimestamp; // nickname VoicedList m_voicedList; QMutex m_mtxNetworkChannelsIteration; QMutex m_mtxvoiceGateRequestsTimestamp; };