pengrad / java-telegram-bot-api

Telegram Bot API for Java

Home Page:https://core.telegram.org/bots

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MessageEntity / User

rainman-wf opened this issue · comments

Hello! I need to save message text with entities to edit it inline buttons later keeping message in original view. I've created corresponding DB tables to save message data. But I can't create User object to put it into Entity user field, because all User class fields are private and has no setters.

I see...
May I suggest you a workaround with data serialization in Json?
You can have another field in DB which will store json data.

You will save it via:

String jsonString = new Gson().toJson(user);
// save string to DB

And read it creating entities as:

// load json string from DB
User user = new Gson().fromJson("{id: 12312}", User.class);

So... I haven't other choice right now. But it's not the best practice. It would be great you provide this feature in a future update.

Thank you!