Files
QtTelegramBot/examples/echo/main.cpp
Moritz Sternemann 3663fd38ce Initial commit
2015-12-29 16:44:16 +01:00

28 lines
598 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(message.from.id, message.string);
}
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
bot = new Telegram::Bot(TOKEN, false, 500, 4);
QObject::connect(bot, &Telegram::Bot::message, &newMessage);
qDebug() << "Started Telegram Bot";
return a.exec();
}