#ifndef TELEGRAMBOTBASE_H
#define TELEGRAMBOTBASE_H

#include <QObject>
#include "telegrambotapi.h"

class TelegramBotBase : public QObject
{
	Q_OBJECT
public:
	explicit TelegramBotBase(QObject *parent = 0);
	TelegramBotAPI * getAPI() {return &api;}



public slots:
	void sendMessageToAll(const QString & message);
	void setBotToken(QString token) {api.setBotToken(token);}

protected:
	struct User {
		User() {
			user_id = 0;
			logged_in = false;
		}
		uint user_id;
		bool logged_in;
		QString user_name;
		QDateTime last_timestamp;
	};

	const User & getUser(uint id) {return users[id];}
	virtual QString welcome(uint id);
	virtual QString loginMessage(uint id);
	virtual QString help();
	virtual bool loginUser(uint id, const QString & msg);
	virtual void messageFromUser(uint id, const QString & msg);
	virtual void newUser(uint id, User user);
	void disconnectUser(uint id);

private slots:
	void processMessage(TelegramBotAPI::Message msg);

private:
	QMap<uint, User> users;
	TelegramBotAPI api;

	QString m_botToken;

signals:

};

#endif // TELEGRAMBOTBASE_H
