refactor
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#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"
|
||||
|
||||
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;
|
||||
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 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 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
|
||||
Reference in New Issue
Block a user