A Telegram Bot for printing out the JSON data of a message sent or forwarded with support of navigating through the data and selecting individual data.
Telegram bot that can show the JSON raw data of a sent message, appended with functioning buttons to navigate through the JSON object. This bot's working flow is inspired by JSONShowBot which is not working as of November 2021.
The code is not perfect. Still have minor (major?) bugs.
- grammY: Telegram Bot Framework. (Docs - npm)
- Deta.sh: NoSQL Database.
- Packages:
deta
,dotenv
,envalid
,express
,grammy
,number-to-words
- Clone this repository:
git clone https://github.com/dcdunkan/show-json-bot
- Install dependencies:
npm install
. - Create a
.env
file and set ENV variables exceptDOMAIN
- Like in.env.example
file. Set optionals if you want to. - Add the following to the end of
src/bot.js
bot.start();
- Run:
npm run local
.
You don't really have to deploy this. Running one, here - @jsoonbot. See the environment variable section for deploying details.
You can deploy to Heroku or Railway. Both of them has a free plan with some limits. The demo bot is running on Heroku.
2 kinds of environmental variables. You must to set required ENV vars. You can set optionals if you want the additional features(?) as said in the descriptions.
This is all you need to setup this bot basically. Don't care about DB_ENABLE
and CHAT_LOG
if you only want basic (main focus of this bot) things to work.
Variable | Description |
---|---|
BOT_TOKEN |
You can get a Telegram Bot token by chatting with the BotFather here: BotFather |
DOMAIN |
This bot uses Webhooks to recieve updates from Telegram. Set this to your app's domain without https:// or http:// or an / at the end. For example, on heroku, <appname>.herokuapp.com |
Variable | Required? | Description |
---|---|---|
DB_ENABLE |
Optional. | Defaults to false . Set this to true if you want the bot to store user IDs and user count to Deta.sh Bases. You have to configure DETA_KEY also. |
DETA_KEY |
Required, if DB_ENABLE is true . |
Deta.sh project key. Create a free account in deta, and create a new project from dashboard, copy it's project key and set it here. |
CHAT_LOG |
Optional. | Defaults to false . Set to true , if you want to log errors, up status, total user count and total number of JSON showed to a Telegram Chat. |
CHAT_ID |
Required, if CHAT_LOG is true . |
A Telegram Chat ID where the bot have permission to send messages. The bot will log errors, up status in this chat. |
USERS_MSG_ID |
Required, if both DB_ENABLE and CHAT_LOG is set to true . |
Set this to a valid id of an existing message in your CHAT ID . Bot should have permission to edit message. Set this if you want the bot to update user count in the log chat. |
SHOWED_JSON_MSG_ID |
Required, if both DB_ENABLE and CHAT_LOG is set to true . |
Set this to a valid id of an existing message in your CHAT ID . Bot should have permission to edit message. Set this if you want the bot to update total json showed count in the log chat. |
If you liked this repo or the bot, please consider giving ⭐️ Star. Also, join our channel for more bot updates: Bots.DC