first commit
This commit is contained in:
+485
@@ -0,0 +1,485 @@
|
||||
#ifndef UGENERAL_H
|
||||
#define UGENERAL_H
|
||||
|
||||
// ============================================================================
|
||||
// ВКЛЮЧЕНИЕ ЗАГОЛОВОЧНЫХ ФАЙЛОВ
|
||||
// ============================================================================
|
||||
#include <QMainWindow>
|
||||
#include <tauth.h>
|
||||
#include <ulink.h>
|
||||
#include <udatabase.h>
|
||||
#include <soundmanager.h>
|
||||
#include "fcreatechat.h"
|
||||
#include "fcreatenotify.h"
|
||||
#include "neuralnetworkmanager.h"
|
||||
#include "ttw_api.h"
|
||||
#include "user_manager.h"
|
||||
#include "webserverchat.h"
|
||||
#include "webservernotify.h"
|
||||
#include "websocketclient.h"
|
||||
#include "userwidget.h"
|
||||
#include <QTimer>
|
||||
#include "emoteprovider.h"
|
||||
#include "timerinfo.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class uGeneral; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
// Структура для отправки сообщений
|
||||
struct MessageData {
|
||||
QString nickname;
|
||||
QString content;
|
||||
QString eventType; // Для уведомлений
|
||||
QVariantMap styleSettings; // Настройки стилей
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// КЛАСС UGeneral - ГЛАВНОЕ ОКНО ПРИЛОЖЕНИЯ
|
||||
// ============================================================================
|
||||
class uGeneral : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
// Переопределение обработчика закрытия окна
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public:
|
||||
// Конструктор и деструктор
|
||||
uGeneral(QWidget *parent = nullptr);
|
||||
~uGeneral();
|
||||
|
||||
// ========================================================================
|
||||
// СТРУКТУРЫ ДАННЫХ
|
||||
// ========================================================================
|
||||
|
||||
// Данные для авторизации Twitch
|
||||
struct TTTVAuth {
|
||||
QString botName;
|
||||
QString botToken;
|
||||
QString strimerToken;
|
||||
QString ClientID;
|
||||
QString channelName;
|
||||
};
|
||||
|
||||
// Структура для хранения пар команд (вопрос-ответ)
|
||||
struct RListCommands {
|
||||
QString R1;
|
||||
QString R2;
|
||||
RListCommands() = default;
|
||||
RListCommands(const QString &r1, const QString &r2) : R1(r1), R2(r2) {}
|
||||
};
|
||||
|
||||
// Запись лога
|
||||
struct LogEntry {
|
||||
QDateTime time;
|
||||
QString module;
|
||||
QString method;
|
||||
QString message;
|
||||
int code;
|
||||
QString msgType;
|
||||
QColor color;
|
||||
};
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// ПУБЛИЧНЫЕ ЧЛЕНЫ КЛАССА
|
||||
// ========================================================================
|
||||
QList<RListCommands> TCommends; // Список команд
|
||||
BTTVProvider bttvProvider;
|
||||
SevenTVProvider sevenTVProvider;
|
||||
uDataBase *db; // Указатель на базу данных
|
||||
SoundManager *soundManager; // Менеджер звуков
|
||||
UserManager* getUserManager(); // Получение менеджера пользователей
|
||||
TTwAPI *twitchAPI; // API для работы с Twitch
|
||||
|
||||
// Методы логирования и работы с командами
|
||||
void toLog(QString aModule, QString aMethod, QString aMessage, int aCode);
|
||||
void toCommands(QString command, QString response);
|
||||
|
||||
private slots:
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ТАЙМЕРАМИ
|
||||
// ========================================================================
|
||||
void on_btnTimerAdd_clicked();
|
||||
void on_btnTimerEdit_clicked();
|
||||
void on_btnTimerDelete_clicked();
|
||||
void on_btnTimerTest_clicked();
|
||||
void on_sgTimers_cellClicked(int row, int column);
|
||||
void on_sgTimers_cellDoubleClicked(int row, int column);
|
||||
void onTimerTimeout(int timerId);
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ АВТОРИЗАЦИИ И НАСТРОЕК
|
||||
// ========================================================================
|
||||
void on_btnGetTockenBot_clicked(); // Получение токена бота
|
||||
void on_btnOpenFolderSettings_clicked(); // Открытие папки настроек
|
||||
void on_btnGetTokenStreamer_clicked(); // Получение токена стримера
|
||||
void on_btnDAGetCode_clicked(); // Получение кода DA
|
||||
|
||||
// Обработчики получения токенов
|
||||
void onTokenReceived(const QString &token);
|
||||
void onTokenReceived2(const QString &token);
|
||||
void onTokenReceived3(const QString &token);
|
||||
void onAuthError(const QString &error); // Ошибка авторизации
|
||||
|
||||
// Работа с настройками
|
||||
void loadSettings(); // Загрузка настроек
|
||||
void on_btnImportSettings_clicked(); // Импорт настроек
|
||||
void on_btnExportSettings_clicked(); // Экспорт настроек
|
||||
void on_btnSaveSettings_clicked(); // Сохранение настроек
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С УВЕДОМЛЕНИЯМИ
|
||||
// ========================================================================
|
||||
void on_btnNotifyCheck_clicked(); // Проверка обычных уведомлений
|
||||
void on_btnNotifyCheckMod_clicked(); // Проверка уведомлений для модераторов
|
||||
void on_btnNotifyCheckVip_clicked(); // Проверка уведомлений для VIP
|
||||
void on_btnNotifyCheckSub_clicked(); // Проверка уведомлений для подписчиков
|
||||
|
||||
void on_btnNotifyOpen_clicked(); // Открытие обычных уведомлений
|
||||
void on_btnNotifyOpenMod_clicked(); // Открытие уведомлений для модераторов
|
||||
void on_btnNotifyOpenVip_clicked(); // Открытие уведомлений для VIP
|
||||
void on_btnNotifyOpenSub_clicked(); // Открытие уведомлений для подписчиков
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С WEBSOCKET (TWITCH)
|
||||
// ========================================================================
|
||||
void onStatus(const QString &statusText, int statusCode);
|
||||
void onDisconnected(const QString &reason);
|
||||
void onJoined(const QString &nickname);
|
||||
void onMessage(const QString &message);
|
||||
void handleNewMessage(const QString &message);
|
||||
void handleError(const QString &errorMessage);
|
||||
void handleConnected();
|
||||
void handleDisconnected();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С КОМАНДАМИ И ОТВЕТАМИ
|
||||
// ========================================================================
|
||||
void execCommand(const QString &sender, const QString &message);
|
||||
QString ResponsParserStatic(const QString &inMess, const QString &adName, const QString &aCommandText);
|
||||
QString ResponsParserRandoms(const QString &inMess);
|
||||
QString ResponsParserSounds(const QString &inMess);
|
||||
QString ResponsParserText(const QString &inMess);
|
||||
QString ResponsParserAI(const QString &response, const QString &pall);
|
||||
QString responsParserAPI(const QString &inMess, const QString &adName);
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ИСКУССТВЕННЫМ ИНТЕЛЛЕКТОМ
|
||||
// ========================================================================
|
||||
void onAIResponseReceived(const QString &response);
|
||||
void onAIErrorOccurred(const QString &error);
|
||||
void onNeuralResponse(const QString &response);
|
||||
void onNeuralError(const QString &error);
|
||||
void sendRequestToAI(const QString &q);
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С TWITCH API
|
||||
// ========================================================================
|
||||
void onApiError(const QString &method, const QString &error);
|
||||
void onTokenExpired(const QString &error);
|
||||
void onRateLimit();
|
||||
void initTwitchAPI();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ИНТЕРФЕЙСОМ
|
||||
// ========================================================================
|
||||
// Радиокнопки выбора режима
|
||||
void on_RBCustom_pressed();
|
||||
void on_rbGC_clicked();
|
||||
void on_rbDS_clicked();
|
||||
void on_rbCG_clicked();
|
||||
|
||||
// Кнопки управления
|
||||
void on_pushButton_2_clicked();
|
||||
void on_pushButton_clicked();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ЛОГАМИ
|
||||
// ========================================================================
|
||||
void applyLogFilter();
|
||||
void addLogToTable(const LogEntry &entry, int row);
|
||||
bool shouldShowLogEntry(int code);
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ТАБЛИЦАМИ И ГРИДАМИ
|
||||
// ========================================================================
|
||||
void on_sgCommands_cellDoubleClicked(int row, int column);
|
||||
void onSoundGridDoubleClicked();
|
||||
void onFilesGridDoubleClicked();
|
||||
void onNeiroGridDoubleClicked();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С РАНДОМНЫМИ ОТВЕТАМИ
|
||||
// ========================================================================
|
||||
void on_lbRandomGroup_itemClicked(QListWidgetItem *item);
|
||||
void on_lbRandomGroup_doubleClicked(const QModelIndex &index);
|
||||
void on_lbRandomRespons_itemDoubleClicked(QListWidgetItem *item);
|
||||
|
||||
void on_btnRandAdd_clicked();
|
||||
void on_btnRandDel_clicked();
|
||||
void on_btnRandomAdd_clicked();
|
||||
void on_btnRandomDel_clicked();
|
||||
void on_btnRmGroup_clicked();
|
||||
|
||||
void on_sgRandomInt_cellClicked(int row, int column);
|
||||
void on_sgRandomInt_cellDoubleClicked(int row, int column);
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ПОЛЬЗОВАТЕЛЯМИ
|
||||
// ========================================================================
|
||||
void on_btnAddUserName_clicked();
|
||||
void on_btnGetDateFollow_clicked();
|
||||
void on_btnGetAgeAccaunt_clicked();
|
||||
void on_btnRandomUserName_clicked();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С КОМАНДАМИ ЧАТА
|
||||
// ========================================================================
|
||||
void on_btnAddCommand_clicked();
|
||||
void on_btnRmCommand_clicked();
|
||||
void on_btnEdtCommand_clicked();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С КАНАЛОМ И ДОП. ФУНКЦИЯМИ
|
||||
// ========================================================================
|
||||
void on_btnGetChannelStat_clicked();
|
||||
void on_btnGPT_clicked();
|
||||
void on_btnAIPic_clicked();
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ТЕМАМИ
|
||||
// ========================================================================
|
||||
void on_cbTheme_currentIndexChanged(int index);
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// СЛОТЫ ДЛЯ РАБОТЫ С ВЕБ СЕРВЕРАМИ
|
||||
// ========================================================================
|
||||
void on_btnWSCreateChat_clicked();
|
||||
void on_btnWSCreateNotify_clicked();
|
||||
|
||||
void onChatServerUpdated(HttpServerChat *server, const QString &name);
|
||||
void on_sgWebServers_cellDoubleClicked(int row, int column);
|
||||
|
||||
void onChatServerCreated(HttpServerChat *server, const QString &name);
|
||||
void onNotifyServerCreated(HttpServer *server, const QString &name);
|
||||
|
||||
// Методы для внешнего добавления уведомлений и сообщений
|
||||
void addNotification(const QString &nickname = "", double amount = 0, const QString &type = "donation");
|
||||
QString processTwitchMessage(const TwitchMessage &msg);
|
||||
QString replaceTwitchEmotes(const QString &emotesData, const QString &message);
|
||||
QString replaceCustomEmotes(const QString &message);
|
||||
|
||||
|
||||
void sendMessageToServer(HttpServerChat *server, const QString &nickname,
|
||||
const QString &message);
|
||||
|
||||
// Обновленный метод addChatMessage
|
||||
void addChatMessage(const QString &nickname,
|
||||
const QString &message);
|
||||
|
||||
void on_www_currentChanged(int index);
|
||||
|
||||
void on_edtBotName_selectionChanged();
|
||||
|
||||
void on_edtBotName_editingFinished();
|
||||
|
||||
void on_edtBotToken_textEdited(const QString &arg1);
|
||||
|
||||
void on_edtBotToken_editingFinished();
|
||||
|
||||
void on_edtBotTokenStreamer_editingFinished();
|
||||
|
||||
void on_edtBotClientID_editingFinished();
|
||||
|
||||
void on_edtChannel_editingFinished();
|
||||
|
||||
void on_edtDAClientID_editingFinished();
|
||||
|
||||
void on_edtDAClientSecret_editingFinished();
|
||||
|
||||
void on_edtDARedirectURL_editingFinished();
|
||||
|
||||
void on_edtDACode_editingFinished();
|
||||
|
||||
void on_cbDAAutoLogin_checkStateChanged(const Qt::CheckState &arg1);
|
||||
|
||||
void on_cbDAAutoLogin_stateChanged(int arg1);
|
||||
|
||||
void on_edtGPTPrefix_editingFinished();
|
||||
|
||||
void on_edtAIP1_editingFinished();
|
||||
|
||||
void on_edtAIP2_editingFinished();
|
||||
|
||||
void on_edtAIP3_editingFinished();
|
||||
|
||||
void on_edtKandiKey_editingFinished();
|
||||
|
||||
void on_edtKandiSecret_editingFinished();
|
||||
|
||||
void on_cbOllama_stateChanged(int arg1);
|
||||
|
||||
void on_tbNotifyVolume_valueChanged(int value);
|
||||
|
||||
void on_edtNotifyFileName_editingFinished();
|
||||
|
||||
void on_edtNotifyFileNameMod_editingFinished();
|
||||
|
||||
void on_edtNotifyFileNameVip_editingFinished();
|
||||
|
||||
void on_edtNotifyFileNameSub_editingFinished();
|
||||
|
||||
void on_chEnNotify_stateChanged(int arg1);
|
||||
|
||||
void on_chEnNotifyMod_stateChanged(int arg1);
|
||||
|
||||
void on_chEnNotifyVip_stateChanged(int arg1);
|
||||
|
||||
void on_chEnNotifySub_stateChanged(int arg1);
|
||||
|
||||
void on_tbNotifyVolume_sliderPressed();
|
||||
|
||||
void on_tbNotifyVolume_sliderReleased();
|
||||
|
||||
void on_tbNotifyVolumeMod_sliderReleased();
|
||||
|
||||
void on_tbNotifyVolumeVip_sliderReleased();
|
||||
|
||||
void on_tbNotifyVolumeSub_sliderReleased();
|
||||
|
||||
void on_cbNotifyFileAgain1_stateChanged(int arg1);
|
||||
|
||||
void on_cbNotifyFileAgain2_stateChanged(int arg1);
|
||||
|
||||
void on_cbNotifyFileAgain3_stateChanged(int arg1);
|
||||
|
||||
void on_btnThemesFolder_clicked();
|
||||
|
||||
public slots:
|
||||
// Установка статуса подключения к Twitch
|
||||
void setTwitchConnected(bool connected);
|
||||
|
||||
private:
|
||||
// ========================================================================
|
||||
// ПРИВАТНЫЕ ЧЛЕНЫ КЛАССА
|
||||
// ========================================================================
|
||||
Ui::uGeneral *ui; // Указатель на интерфейс
|
||||
// Объекты для авторизации
|
||||
TAuth *m_authBot; // Авторизация бота
|
||||
TAuth *m_authStreamer; // Авторизация стримера
|
||||
TAuth *m_authDA; // Авторизация DA
|
||||
|
||||
uLink *fLinkForm; // Форма ссылок
|
||||
TTTVAuth *TTVAuth; // Данные авторизации Twitch
|
||||
UserManager *m_userManager; // Менеджер пользователей
|
||||
QList<LogEntry> allLogs; // Все записи логов
|
||||
|
||||
WebSocketClient *m_twitchClient; // WebSocket клиент для Twitch
|
||||
UserWidget* m_userWidget; // Виджет пользователя
|
||||
NeuralNetworkManager *nnManager; // Менеджер нейронных сетей
|
||||
|
||||
QList<TimerInfo> m_timers; // Список таймеров
|
||||
int m_nextTimerId = 1; // Следующий ID таймера
|
||||
bool m_isTwitchConnected = false; // Статус подключения к Twitch
|
||||
|
||||
// Менеджеры веб-серверов
|
||||
QList<HttpServer*> m_notificationServers;
|
||||
QList<HttpServerChat*> m_chatServers;
|
||||
|
||||
// Для связи с окнами создания
|
||||
FCreateNotify *m_createNotifyDialog;
|
||||
FCreateChat *m_createChatDialog;
|
||||
QVector<ChatBadge> m_chatBadges;
|
||||
// Методы для обработки бейджей и форматирования ника
|
||||
QString formatNicknameWithBadges(const TwitchMessage &msg);
|
||||
QString getBadgesHTML(const TwitchMessage &msg);
|
||||
QString getBadgeUrl(const QString &setId, int versionId);
|
||||
QVector<QIcon> tabIcons;
|
||||
// Структура для замены эмодзи
|
||||
struct EmoteReplacement {
|
||||
int start;
|
||||
int length;
|
||||
QString html;
|
||||
};
|
||||
|
||||
// Добавление серверов в списки и таблицу
|
||||
void addNotificationServer(HttpServer *server, const QString &name);
|
||||
void addChatServer(HttpServerChat *server, const QString &name);
|
||||
void addServerToTable(const QString &name, const QString &type, quint16 port,
|
||||
const QString &url, QObject *serverObj);
|
||||
|
||||
// Вспомогательные методы
|
||||
int findNotificationServerRow(HttpServer *server);
|
||||
int findChatServerRow(HttpServerChat *server);
|
||||
QString generateServerId() const;
|
||||
|
||||
|
||||
// Текущие настройки для формы
|
||||
QVariantMap m_currentSettings;
|
||||
|
||||
// ========================================================================
|
||||
// ПРИВАТНЫЕ МЕТОДЫ
|
||||
// ========================================================================
|
||||
|
||||
// Метод для загрузки списка QSS файлов
|
||||
void loadQssFiles();
|
||||
// Метод для применения QSS темы
|
||||
void applyStyleSheet(const QString &filename);
|
||||
|
||||
QString getUserFilePath(const QString &type, const QString &fileName) const;
|
||||
QString getUserDataPath() const;
|
||||
QString getSystemPath() const;
|
||||
void setupButtonIcons();
|
||||
void loadStylesFromDirectory(const QDir &stylesDir, const QString &category);
|
||||
void copyDefaultFiles();
|
||||
void initializeAppDataStructure();
|
||||
|
||||
// Настройка OAuth для Twitch
|
||||
void setupTwitchOAuth();
|
||||
|
||||
// Инициализация конфигурации ИИ
|
||||
void initAIConfig();
|
||||
void updateAIConfig();
|
||||
QString processAITag(const QString &input, const QString &sender);
|
||||
|
||||
// Работа с таймерами
|
||||
void updateTimerTable();
|
||||
void startTimer(TimerInfo& timerInfo);
|
||||
void stopTimer(TimerInfo& timerInfo);
|
||||
void sendTimedMessage(const TimerInfo& timerInfo);
|
||||
|
||||
// Воспроизведение уведомлений
|
||||
void playNotify(const bool &isMod, const bool &isVip, const bool &isSub);
|
||||
|
||||
|
||||
// Инициализация базы данных
|
||||
void initializeDatabase();
|
||||
// Настройка пользовательского интерфейса
|
||||
void setupUI();
|
||||
// Настройка таблиц интерфейса
|
||||
void setupTables();
|
||||
// Инициализация менеджеров
|
||||
void initializeManagers();
|
||||
// Настройка компонентов Twitch
|
||||
void setupTwitchComponents();
|
||||
// Настройка виджета пользователей
|
||||
void setupUserWidget();
|
||||
// Настройка обработчиков авторизации
|
||||
void setupAuthHandlers();
|
||||
// Инициализация нейронной сети
|
||||
void initializeNeuralNetwork();
|
||||
// Загрузка эмодзи
|
||||
void loadEmoties();
|
||||
void loadChatBadges();
|
||||
|
||||
// Обработка эмодзи
|
||||
void processEmotes(QString &message);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // UGENERAL_H
|
||||
Reference in New Issue
Block a user