Files
QtTelegramBot/examples/echo/main.cpp
2017-05-05 21:15:40 +02:00

28 lines
605 B
C++

#include <QCoreApplication>
#include <QDebug>
#include "qttelegrambot.h"
#define TOKEN "YOUR BOT TOKEN"
Telegram::Bot *bot;
void newMessage(Telegram::Message message)
{
qDebug() << "new message:" << message;
if (bot && message.type == Telegram::Message::TextType) {
bot->sendMessage((qint32)message.from.id, message.string);
}
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
bot = new Telegram::Bot(TOKEN, true, 500, 4);
QObject::connect(bot, &Telegram::Bot::message, &newMessage);
qDebug() << "Started Telegram Bot";
return a.exec();
}