81 lines
2.7 KiB
C++
81 lines
2.7 KiB
C++
#ifndef COMMANDPROCESSOR_H
|
|
#define COMMANDPROCESSOR_H
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QVector>
|
|
#include <QMap>
|
|
#include <QDate>
|
|
#include "mediafilemanager.h"
|
|
#include "user_manager.h"
|
|
#include "ttw_api.h"
|
|
#include "soundmanager.h"
|
|
#include "neuralnetworkmanager.h"
|
|
#include "randommanager.h"
|
|
#include "randomresponses.h"
|
|
#include "neuraltemplatemanager.h"
|
|
|
|
class CommandProcessor : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
struct Command {
|
|
QString command;
|
|
QString response;
|
|
};
|
|
|
|
struct Context {
|
|
UserManager* userManager = nullptr;
|
|
TTwAPI* twitchAPI = nullptr;
|
|
SoundManager* soundManager = nullptr;
|
|
NeuralNetworkManager* neuralManager = nullptr;
|
|
RandomManager* randomManager = nullptr;
|
|
RandomResponses* randomResponses = nullptr;
|
|
MediaFileManager* mediaFileManager = nullptr;
|
|
NeuralTemplateManager *neuralTemplateManager = nullptr;
|
|
QString channel;
|
|
int notifyVolume = 50;
|
|
};
|
|
|
|
explicit CommandProcessor(QObject *parent = nullptr);
|
|
|
|
void setContext(const Context& context);
|
|
|
|
QString generateResponse(QString userIndex, const QString &command, const QString &message = "");
|
|
|
|
void addCommand(const QString &command, const QString &response);
|
|
void editCommand(const QString &oldCommand,const QString &newCommand,const QString &response);
|
|
void deleteCommand(const QString &commandName);
|
|
|
|
void addCommands(const QVector<Command> &commands);
|
|
void clearCommands();
|
|
|
|
Command findCommand(const QString &commandName) const;
|
|
|
|
private:
|
|
Context m_context;
|
|
QVector<Command> m_commands;
|
|
|
|
QString processCommand(const QString &sender, const QString &fullCommand, const QString &rawResponse);
|
|
QString parseStatic(const QString &response, const QString &sender, const QString ¶meters);
|
|
QString parseRandomNumbers(const QString &response);
|
|
QString parseSounds(const QString &response);
|
|
QString parseTextFiles(const QString &response);
|
|
QString parseRandomGroups(const QString &response);
|
|
QString parseBan(const QString &response, const QString &sender);
|
|
QString parseAPI(const QString &response, const QString &sender);
|
|
QString parseAI(const QString &response, const QString &question);
|
|
QString parseNeuralTemplates(const QString &response, const QString &sender, const QString ¶meters);
|
|
|
|
QString extractParameters(const QString &fullCommand);
|
|
QString getUsernameByIndex(QString userIndex) const;
|
|
QString getDateDifferenceString(const QDate &inputDate);
|
|
QString getPeriodEnding(int n, int r);
|
|
|
|
QString getRandomResponseFromGroup(const QString &groupName);
|
|
QString getTextFileContent(const QString &fileName);
|
|
};
|
|
|
|
#endif // COMMANDPROCESSOR_H
|