rubenlagus / TelegramBotsExample

A simple to use library to create Telegram Bots in Java
GNU General Public License v3.0
479 stars 227 forks source link

Really necessary mySql using? #14

Closed DoubleBoba closed 8 years ago

DoubleBoba commented 8 years ago

Can I disable database using, or use sqlite? If i simply change driver, it blow up on syntax problems in hardcoded queries.

rubenlagus commented 8 years ago

The example bots I build are using MySql, I don't think the queries can be used in sqlite directly.

If you want to use a different database, you should update the queries in "DatabaseManager.java".

The database is needed because it is used to store user state for each bot and also users preferences. In addition, I use it to store last received update so, in case of restart, bot can continue fetching the updates correctly using getUpdates method.

In any case, it is possible to fully remove the database, but it isn't easy:

  1. Use webhook method (setting it in BuildVars correctly)
  2. Don't use any of the bots examples.
DoubleBoba commented 8 years ago

I don`t know, is it good practice. I remove all DB using by commenting two lines of code in UpdatesThread. All work fine. And i remove all example code from library. My UpdatesThread class: https://gist.github.com/kingofsystem/40f65577a16bef2a87db

rubenlagus commented 8 years ago

I suggest you to store, somewhere, the last received updateId, that way you will avoid answering twice same message if, for any reason, your bot need to be restarted.

rubenlagus commented 8 years ago

@kingofsystem You can now use this without any kind of database just fetch it from https://jitpack.io/#rubenlagus/TelegramBots/v1.0 or download the jar from https://github.com/rubenlagus/TelegramBots/releases/tag/v1.0

Hopefully should work.