FakeDataTelegramBot β Generate Fake Data (JSON / SQL / CSV)¶
Telegram bot that interactively generates fake datasets and sends them back as a file.
Powered by Java 20, Maven, java-telegram-bot-api, Lombok, and JavaFaker.
Note: The current implementation supports JSON, SQL, and CSV. (βCβ structs are not implemented in this codebase.)
β¨ Features¶
- Chat-based wizard using inline keyboards:
/generateβ File name β Format (json/sql/csv) β Row count β Fields β βοΈ Generate.- Built-in field library (via
FieldTypeenum) such asFULL_NAME,FIRST_NAME,AGE,CITY,BOOK_TITLE,CELL_PHONE,GENDER, etc. - Formats:
- JSON: array of objects
- SQL:
INSERT INTO <file_name_format>statements - CSV: header + rows, commas safely quoted
- Sends the generated file to the chat and deletes the temp file on disk.
π§± Tech Stack¶
- Java 20, Maven project (
groupId=org.example,artifactId=FakeDataTelegramBot). - Dependencies:
com.github.pengrad:java-telegram-bot-api:6.8.0org.projectlombok:lombok:1.18.28(scopeprovided)com.github.javafaker:javafaker:1.0.2
π¦ Project Structure & Key Classes¶
TelegramBotRunner: entry point that starts the bot, registersUpdatesListener, and dispatches updates on a thread pool. Readsbot.tokenfromsettingsbundle.TelegramBotUpdateHandler: main conversation handler implementing the step-by-step wizard, inline keyboards, file sending, and temp file cleanup.FakeDataGenerator: core generator:- Maps each
FieldTypeβSupplier<Object>using Faker - Writers for
json,sql, andcsv - Returns a
Pathto the generated file FieldType: enum of supported fields + helpers for quoting/formatting JSON & SQL values.Pairs:(fieldName, fieldType)pair chosen by the user.Request: generation request(fileName, count, type, pairs).Main: a tiny demo that instantiatesFakeDataGenerator(not used in production bot flow).
π§ Setup & Run¶
- Configure token
Create asettings.propertieson the classpath (e.g., insrc/main/resources):
bot.token=YOUR_TELEGRAM_BOT_TOKEN
- Build
mvn clean package
- Run
java -cp target/FakeDataTelegramBot-1.0-SNAPSHOT.jar org.example.TelegramBotRunner
π¬ Usage (in Telegram)¶
- Start a chat with your bot and send:
/start
- Begin generation:
/generate
-
Choose fields via inline keyboard
Tap any number of fields (fromFieldTypeenum).
Hit βοΈ Generate to create and receive the file. -
The bot sends the file and cleans up the temp file.
π Supported Fields (FieldType)¶
| FieldType | Example / Notes |
|---|---|
FULL_NAME |
"Aisha Karimova" |
FIRST_NAME |
"Bek" |
LAST_NAME |
"Yusupov" |
USERNAME |
"Clara" (uses firstName) |
TITLE |
job title |
BLOOD_GROUP |
from name.bloodGroup() |
WORDS |
faker lorem words |
CHARACTERS |
single/random character |
CITY |
country capital |
COUNTRY |
country name |
COUNTRY_CODE |
ISO-2 country code |
ZIP_CODE |
postal code |
BOOK_AUTHOR |
author |
BOOK_GENRE |
genre |
BOOK_PUBLISHER |
publisher |
BOOK_TITLE |
title |
CELL_PHONE |
phone number |
AGE |
int 1β100 |
ID |
int 10000β99999 |
GENDER |
"Male" / "Female" |
π Output Formats¶
JSON¶
- Array of objects with selected fields.
SQL¶
- Multiple
INSERT INTO <file_name_format> (...) VALUES (...);
CSV¶
- Header = selected field names; values quoted when they contain commas.
π§ Conversation State Machine¶
State enum drives the wizard:
FILE_NAMEβTYPEβROW_COUNTβFIELDS
π§© Implementation Notes¶
- Keyboard: Inline keyboard built from
FieldType.values()(two columns), plus a final row ββοΈ Generateβ. - Concurrency: Updates are handled with
CompletableFuture.runAsyncon a fixed thread pool. - Cleanup: After sending
SendDocument, the generated file is deleted viaFiles.delete(...).
π¦ Limitations & To-Dos¶
- C structs output is not implemented (formats are
json,sql,csvin code). - No per-field constraints (e.g., ranges for
AGE) beyond defaults. - No schema persistence across sessions.
- Minimal error messaging for invalid inputs.
Ideas to extend:
- Add c formatter (struct + initializer).
- Add CREATE TABLE for SQL with type inference.
- Add locales and seed configuration commands.
- Persist last-used field sets per user.
π‘οΈ Safety¶
- Generated data is synthetic.
- Large row counts produce large files.
- Bot token is read from
settings.propertiesβ keep it secret.
π License¶
Add your preferred license (e.g., MIT) to the repository.
π©βπ» Development Quick Reference¶
- Java 20 / Maven compiler configuration is set in the POM.
- Libraries:
java-telegram-bot-apifor Telegram integrationjavafakerfor data generationlombokfor boilerplate reduction