git-svn-id: svn://db.shs.com.ru/libs@131 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
#include "execbot.h"
|
#include "execbot.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
ExecBot::ExecBot(QObject *parent) : TelegramBotBase(parent) {
|
ExecBot::ExecBot(QObject *parent) : TelegramBotBase(parent) {
|
||||||
|
connect(getAPI(), SIGNAL(newFile(TelegramBotAPI::File)), this, SLOT(saveFile(TelegramBotAPI::File)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +31,7 @@ bool ExecBot::loginUser(uint id, const QString &msg) {
|
|||||||
if (msg == "/start") sessions[id] = Password;
|
if (msg == "/start") sessions[id] = Password;
|
||||||
break;
|
break;
|
||||||
case Password:
|
case Password:
|
||||||
if (msg == "shspasswd") {
|
if (msg == "rootpasswd") {
|
||||||
sessions[id] = Ready;
|
sessions[id] = Ready;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -60,18 +64,31 @@ void ExecBot::messageFromUser(uint id, const QString &msg) {
|
|||||||
int rm = -1;
|
int rm = -1;
|
||||||
for (int i=0; i<run_commands.size(); i++) {
|
for (int i=0; i<run_commands.size(); i++) {
|
||||||
if (run_commands[i].user == id) {
|
if (run_commands[i].user == id) {
|
||||||
run_commands[i].cmd->kill();
|
run_commands[i].cmd->terminate();
|
||||||
getAPI()->sendMessage(id, tr("Process killed"));
|
getAPI()->sendMessage(id, tr("Process killed"));
|
||||||
sessions[id] = Ready;
|
sessions[id] = Ready;
|
||||||
rm = i;
|
rm = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rm >= 0) run_commands.remove(rm);
|
if (rm >= 0) {
|
||||||
|
run_commands[rm].cmd->deleteLater();
|
||||||
|
run_commands.remove(rm);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
getAPI()->sendMessage(id, tr("Command is running, please wait for finish"));
|
getAPI()->sendMessage(id, tr("Command is running, please wait for finish"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sessions[id] == Ready) {
|
if (sessions[id] == Ready) {
|
||||||
|
if (msg.startsWith("/download")) {
|
||||||
|
QFile f;
|
||||||
|
f.setFileName(msg.mid(9).trimmed());
|
||||||
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
|
QByteArray ba = f.readAll();
|
||||||
|
getAPI()->sendMessage(id, TelegramBotAPI::Document, ba, QFileInfo(f).fileName());
|
||||||
|
} else
|
||||||
|
getAPI()->sendMessage(id, tr("File not found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
getAPI()->sendMessage(id, "exec: " + msg);
|
getAPI()->sendMessage(id, "exec: " + msg);
|
||||||
UserCommand uc;
|
UserCommand uc;
|
||||||
uc.user = id;
|
uc.user = id;
|
||||||
@@ -96,28 +113,62 @@ void ExecBot::cmdRead() {
|
|||||||
for (int i=0; i<run_commands.size(); i++) {
|
for (int i=0; i<run_commands.size(); i++) {
|
||||||
if (run_commands[i].cmd == p) {
|
if (run_commands[i].cmd == p) {
|
||||||
int id = run_commands[i].user;
|
int id = run_commands[i].user;
|
||||||
//QTextCodec *codec = QTextCodec::codecForName("IBM 866");
|
#ifdef WIN32
|
||||||
QString s = QString::fromUtf8(p->readAll());//codec->toUnicode(p->readAll());
|
QTextCodec *codec = QTextCodec::codecForName("IBM 866");
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||||
|
#endif
|
||||||
|
QString s = codec->toUnicode(p->readAll());
|
||||||
getAPI()->sendMessage(id, s);
|
getAPI()->sendMessage(id, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecBot::cmdFinish(int code) {
|
void ExecBot::cmdFinish(int code) {
|
||||||
qDebug() << "cmdFinish()" << code;
|
// qDebug() << "cmdFinish()" << code;
|
||||||
QProcess * p = (QProcess *)sender();
|
QProcess * p = (QProcess *)sender();
|
||||||
int rm = -1;
|
int rm = -1;
|
||||||
for (int i=0; i<run_commands.size(); i++) {
|
for (int i=0; i<run_commands.size(); i++) {
|
||||||
if (run_commands[i].cmd == p) {
|
if (run_commands[i].cmd == p) {
|
||||||
int id = run_commands[i].user;
|
int id = run_commands[i].user;
|
||||||
//QTextCodec *codec = QTextCodec::codecForName("IBM 866");
|
#ifdef WIN32
|
||||||
QString s = QString::fromUtf8(p->readAll()); //codec->toUnicode(p->readAll());
|
QTextCodec *codec = QTextCodec::codecForName("IBM 866");
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||||
|
#endif
|
||||||
|
QString s = codec->toUnicode(p->readAll());
|
||||||
getAPI()->sendMessage(id, s);
|
getAPI()->sendMessage(id, s);
|
||||||
rm = i;
|
rm = i;
|
||||||
sessions[id] = Ready;
|
sessions[id] = Ready;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rm >= 0) run_commands.remove(rm);
|
if (rm >= 0) {
|
||||||
|
run_commands[rm].cmd->deleteLater();
|
||||||
|
getAPI()->sendMessage(run_commands[rm].user, tr("Command finished with code %1").arg(code));
|
||||||
|
run_commands.remove(rm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExecBot::saveFile(TelegramBotAPI::File fl) {
|
||||||
|
if (sessions.contains(fl.chat_id)) {
|
||||||
|
if (sessions[fl.chat_id] == Ready) {
|
||||||
|
QFile f;
|
||||||
|
QDir::current().mkdir("uploads");
|
||||||
|
f.setFileName("uploads/" + fl.filename);
|
||||||
|
if (f.open(QIODevice::ReadWrite)) {
|
||||||
|
f.resize(0);
|
||||||
|
f.write(fl.data);
|
||||||
|
getAPI()->sendMessage(fl.chat_id, tr("File received"));
|
||||||
|
} else {
|
||||||
|
getAPI()->sendMessage(fl.chat_id, tr("Can't write file"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getAPI()->sendMessage(fl.chat_id, loginMessage(fl.chat_id));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getAPI()->sendMessage(fl.chat_id, tr("Please send me /start"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void cmdRead();
|
void cmdRead();
|
||||||
void cmdFinish(int code);
|
void cmdFinish(int code);
|
||||||
|
void saveFile(TelegramBotAPI::File fl);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ int main(int argc, char *argv[])
|
|||||||
//MainWindow w;
|
//MainWindow w;
|
||||||
//w.show();
|
//w.show();
|
||||||
ExecBot bot;
|
ExecBot bot;
|
||||||
bot.setBotToken("281218446:AAEaoS25kKZUevp98U-MKiaPGd2kS18d11g");
|
bot.setBotToken("242608352:AAFrx51P_JhmCjV8CV11Mds-LJk89bpolXE");
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
// bot.setBotToken("281218446:AAEaoS25kKZUevp98U-MKiaPGd2kS18d11g");
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QBuffer>
|
|
||||||
#include <QGraphicsPixmapItem>
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
|
||||||
ui->setupUi(this);
|
|
||||||
connect(bot.getAPI(), SIGNAL(newMessage(TelegramBotAPI::Message)), this, SLOT(printMessage(TelegramBotAPI::Message)));
|
|
||||||
connect(bot.getAPI(), SIGNAL(newFile(TelegramBotAPI::File)), this, SLOT(printImage(TelegramBotAPI::File)));
|
|
||||||
// connect(&bot_timer, SIGNAL(timeout()), &bot, SLOT(updateBot()));
|
|
||||||
// bot_timer.start(1000);
|
|
||||||
bot.setBotToken("281218446:AAEaoS25kKZUevp98U-MKiaPGd2kS18d11g");
|
|
||||||
ui->graphicsView->setScene(new QGraphicsScene());
|
|
||||||
ui->graphicsView->setInteractive(false);
|
|
||||||
ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
|
|
||||||
// bot.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_pushButton_1_clicked() {
|
|
||||||
// bot.setBotToken("281218446:AAEaoS25kKZUevp98U-MKiaPGd2kS18d11g");
|
|
||||||
// bot.updateBot();
|
|
||||||
// QImage img(800, 600, QImage::Format_ARGB32);
|
|
||||||
// img.fill(Qt::yellow);
|
|
||||||
// QByteArray ba;
|
|
||||||
// QBuffer buffer(&ba);
|
|
||||||
// buffer.open(QIODevice::WriteOnly);
|
|
||||||
// img.save(&buffer, "PNG");
|
|
||||||
// if (!bot.sendMessageToAll(TelegramBotAPI::Photo, ba, "test.png")) ui->listWidget->addItem("send error");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_pushButton_2_clicked() {
|
|
||||||
if (!ui->lineEdit->text().isEmpty()) {
|
|
||||||
bot.sendMessageToAll(ui->lineEdit->text());
|
|
||||||
ui->listWidget->addItem(QDateTime::currentDateTime().toString() + " #" + bot.getAPI()->botName() + " : " + ui->lineEdit->text());
|
|
||||||
ui->lineEdit->clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::printMessage(TelegramBotAPI::Message msg) {
|
|
||||||
ui->listWidget->addItem(msg.time.toString() + " #" + msg.user_name + " : " + msg.text);
|
|
||||||
lid = msg.chat_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::printImage(TelegramBotAPI::File file) {
|
|
||||||
QImage img;
|
|
||||||
if (img.loadFromData(file.data)) {
|
|
||||||
QPixmap pix = QPixmap::fromImage(img);
|
|
||||||
QListWidgetItem * lwi = new QListWidgetItem(QIcon(pix), file.filename);
|
|
||||||
ui->listWidget->addItem(lwi);
|
|
||||||
ui->graphicsView->scene()->addPixmap(pix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_lineEdit_editingFinished() {
|
|
||||||
on_pushButton_2_clicked();
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QTimerEvent>
|
|
||||||
#include <QTimer>
|
|
||||||
#include "telegrambotbase.h"
|
|
||||||
#include "execbot.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class MainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pushButton_1_clicked();
|
|
||||||
void on_pushButton_2_clicked();
|
|
||||||
void printMessage(TelegramBotAPI::Message msg);
|
|
||||||
void printImage(TelegramBotAPI::File file);
|
|
||||||
|
|
||||||
void on_lineEdit_editingFinished();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::MainWindow *ui;
|
|
||||||
ExecBot bot;
|
|
||||||
uint lid;
|
|
||||||
QTimer bot_timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>MainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>740</width>
|
|
||||||
<height>333</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>MainWindow</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralWidget">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QSplitter" name="splitter">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="listWidget"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Send</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_1">
|
|
||||||
<property name="text">
|
|
||||||
<string>Send image</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QGraphicsView" name="graphicsView">
|
|
||||||
<property name="dragMode">
|
|
||||||
<enum>QGraphicsView::RubberBandDrag</enum>
|
|
||||||
</property>
|
|
||||||
<property name="transformationAnchor">
|
|
||||||
<enum>QGraphicsView::AnchorUnderMouse</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -11,16 +11,15 @@ TEMPLATE = app
|
|||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp \
|
|
||||||
json.cpp \
|
json.cpp \
|
||||||
telegrambotapi.cpp \
|
telegrambotapi.cpp \
|
||||||
telegrambotbase.cpp \
|
telegrambotbase.cpp \
|
||||||
execbot.cpp
|
execbot.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += \
|
||||||
json.h \
|
json.h \
|
||||||
telegrambotapi.h \
|
telegrambotapi.h \
|
||||||
telegrambotbase.h \
|
telegrambotbase.h \
|
||||||
execbot.h
|
execbot.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS +=
|
||||||
|
|||||||
@@ -1,255 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE QtCreatorProject>
|
|
||||||
<!-- Written by QtCreator 3.2.1, 2016-10-19T16:10:33. -->
|
|
||||||
<qtcreator>
|
|
||||||
<data>
|
|
||||||
<variable>EnvironmentId</variable>
|
|
||||||
<value type="QByteArray">{948faa78-0b50-402e-a285-1bca3b08de64}</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
|
||||||
<value type="int">0</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">false</value>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
|
||||||
<value type="QString" key="language">Cpp</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
|
||||||
<value type="QString" key="language">QmlJS</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
|
||||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
|
||||||
<valuemap type="QVariantMap"/>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DesktopBuild</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DesktopBuild</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{3c749452-9483-442d-b011-933a1b5dac10}</value>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Qt_projects/build-telegram_test-DesktopBuild-Debug</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
|
||||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Отладка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Qt_projects/build-telegram_test-DesktopBuild-Release</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
|
||||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
|
||||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Выпуск</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
|
||||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Установка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Локальная установка</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
|
||||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
|
||||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
|
||||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
|
||||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
|
||||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
|
||||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
|
||||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">3</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
|
||||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
|
||||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
|
||||||
<value type="int">0</value>
|
|
||||||
<value type="int">1</value>
|
|
||||||
<value type="int">2</value>
|
|
||||||
<value type="int">3</value>
|
|
||||||
<value type="int">4</value>
|
|
||||||
<value type="int">5</value>
|
|
||||||
<value type="int">6</value>
|
|
||||||
<value type="int">7</value>
|
|
||||||
<value type="int">8</value>
|
|
||||||
<value type="int">9</value>
|
|
||||||
<value type="int">10</value>
|
|
||||||
<value type="int">11</value>
|
|
||||||
<value type="int">12</value>
|
|
||||||
<value type="int">13</value>
|
|
||||||
<value type="int">14</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">telegram_test</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Qt_projects/telegram_test/telegram_test.pro</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">telegram_test.pro</value>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
|
||||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
|
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
|
||||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
|
||||||
<value type="int">1</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
|
||||||
<value type="int">16</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>Version</variable>
|
|
||||||
<value type="int">16</value>
|
|
||||||
</data>
|
|
||||||
</qtcreator>
|
|
||||||
@@ -215,7 +215,7 @@ void TelegramBotAPI::parseMessages(QString json) {
|
|||||||
QVariantMap mm = v.toMap();
|
QVariantMap mm = v.toMap();
|
||||||
last_update = mm.value("update_id").toInt();
|
last_update = mm.value("update_id").toInt();
|
||||||
Message m = parseMessage(mm.value("message"));
|
Message m = parseMessage(mm.value("message"));
|
||||||
if (m.id > 0) {
|
if (m.id > 0 && !m.text.isEmpty()) {
|
||||||
emit newMessage(m);
|
emit newMessage(m);
|
||||||
emit newMessage(m.chat_id, m.text);
|
emit newMessage(m.chat_id, m.text);
|
||||||
}
|
}
|
||||||
@@ -335,7 +335,7 @@ void TelegramBotAPI::sendRequest(QString method, QVariantMap params) {
|
|||||||
QHttpPart part;
|
QHttpPart part;
|
||||||
if (it.value().type() == QVariant::ByteArray) {
|
if (it.value().type() == QVariant::ByteArray) {
|
||||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; filename=\""+filename+"\"; name=\""+it.key()+"\""));
|
part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; filename=\""+filename+"\"; name=\""+it.key()+"\""));
|
||||||
qDebug() << "sending photo" << double(it.value().toByteArray().size()) / (1024*1024);
|
qDebug() << "sending file" << double(it.value().toByteArray().size()) / (1024*1024) << "Mb";
|
||||||
part.setBody(it.value().toByteArray());
|
part.setBody(it.value().toByteArray());
|
||||||
} else {
|
} else {
|
||||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\""+it.key()+"\""));
|
part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\""+it.key()+"\""));
|
||||||
|
|||||||
Reference in New Issue
Block a user