volodalexey / budget-notes-bot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Budget-notes Telegram bot

Live example here @MemoryManagerBot.

  • Create some categories
โ”œโ”€โ”€ ๐Ÿ› num- "1"
โ”œโ”€โ”€ ๐Ÿงธ num- "2"
โ”‚   โ””โ”€โ”€ ๐Ÿ˜ "2.1"
โ”œโ”€โ”€ ๐Ÿ  num- "3"
โ”‚   โ””โ”€โ”€ ๐Ÿงฎ "3.1"
โ””โ”€โ”€ ๐Ÿš— num- "4"
    โ””โ”€โ”€ โ›ฝ๏ธ "4.1"
  • Track some data into categories
  • Obtain your monthly(any timeframe) budget
Total: +81,853.7 (+201,564) (-119,710.3)
โ”œโ”€โ”€ ๐Ÿ’Š: -19,000
โ”œโ”€โ”€ ๐ŸŽ: -18,090
โ”œโ”€โ”€ ๐Ÿงธ: -8,247
โ”œโ”€โ”€ ๐Ÿ‘š: -7,469
โ”œโ”€โ”€ ๐Ÿ›’: -19,955.71
โ”œโ”€โ”€ ๐Ÿ : -6,319.21
โ”‚     โ””โ”€โ”€ ๐Ÿงฎ: -5,541.21
โ”œโ”€โ”€ ๐ŸŒ: -11,459.76
โ”œโ”€โ”€ ๐Ÿช: -7,140.06
โ”œโ”€โ”€ ๐Ÿฝ: -2,635.91
โ”œโ”€โ”€ ๐Ÿš—: -3,712.77
โ”‚     โ””โ”€โ”€ โ›ฝ๏ธ: -3,712.77
โ”œโ”€โ”€ ๐Ÿ’ป: -2,097
โ”œโ”€โ”€ ๐Ÿ›: -8,966.88
โ”œโ”€โ”€ ๐ŸŽ‰: -4,617
โ””โ”€โ”€ ๐Ÿ’ฐ: +201,564
Balance till 18.11.2022 12:41:05 is +291,909.88
  • Track some text data for whatever reason

Run locally

  • install NodeJS, PostgreSQL
  • run npm i
  • create memory (by default) database for PostgreSQL
  • create application at https://my.telegram.org/apps. Select application type - Web, set - empty URL, obtain api id and api hash.
  • create Telegram Bot with BotFather
  • build tdLib for your system, check required version with airgram
  • create .app_rc.json config file

Build npm run build and run bot npm start or cd ./dist and node app.js

  • use bot in private chat or add bot to chat with multiple users (assign bot admin rights to read all messages for better UX)

TbLib vs TelegramBotAPI

TdLib can be used for bot and user. TelegramBotAPI is limited to bots only. Moreover TelegramBotAPI does not support a lot of handy methods, e.g. fetch message by id etc.

  • NodeJS+TypeScript has awesome package for TdLib - Airgram.
  • NodeJS+TypeScript has awesome package for TelegramBotAPI - Telegraf.

Currently TdLib has only one huge minus for NodeJS - you have to build TdLib, but this can change in the future using WASM.

Config

Configuration file is required. See additional info, about cosmiconfig package. Configuration example .app_rc.example.json. You need to create your own config file e.g. .app_rc.json by default.

Environment variables (Debug)

Path to the application config

CONFIG=... node app.js

Debug anything (see all possible values logger.ts)

DEBUG=bnb* node app.js

Tests

For testing you need to have test_section in config file. Jest performs tests.

  • Run tests npm run test
  • Run unit tests npm run test-unit
  • Run integration tests npm run test-int

About


Languages

Language:TypeScript 98.0%Language:PLpgSQL 1.9%Language:JavaScript 0.2%