-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.h
70 lines (58 loc) · 1.29 KB
/
bot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef BOT_H
#define BOT_h
#include <QtNetwork>
#include <QtCore>
#include <QtDBus/QtDBus>
#include <QtScript>
#include <QSettings>
class ScriptFunctions;
class Bot : public QObject, protected QScriptable
{
Q_OBJECT
public:
Bot(const QString &);
void executeScript(const QString &, const QString &);
QString serviceName();
public slots:
void sendMessage(const QString &);
private:
QString serverAddress;
QString nick;
int port;
QString iDent;
QString realName;
QString owner;
QString channel;
QString readBuffer;
QString dataToSend;
QString DBusInterface;
QByteArray block;
QTcpSocket tcpSocket;
quint16 blockSize;
QHash<QString, QScriptEngine *> engines;
ScriptFunctions *scriptFunctions;
friend class ScriptFunctions;
private slots:
void onReadReady();
void onConnect();
void onError(QAbstractSocket::SocketError);
void sendHelp();
public slots:
Q_SCRIPTABLE QString commit(const QString &arg);
};
class ScriptFunctions : public QObject, protected QScriptable
{
Q_OBJECT
public:
ScriptFunctions(Bot *bot);
public slots:
void sendPrivateMessage(const QString &message);
void execute(const QString &program);
private slots:
void handleFinished(int, QProcess::ExitStatus);
private:
Bot *bot;
};
Q_DECLARE_METATYPE(QScriptValue);
Q_DECLARE_METATYPE(QScriptEngine *);
#endif