Skip to content

hse-mtc/hse-military-bot

Repository files navigation

HSE Military Bot Icon

HSE Military Training Center bot for schedule

Gitpod ready-to-code License GitHub release Maintenance Build Status Coverage Status Dependabot Status dependencies Status devDependencies Status

Simply access HSE Military Training Center schedule, prepare news for informing comrades and receive full pack of stickers with people you know well. Stack of technologies used:

  • Awesome Telegraf wrapper for Telegram API.
  • Heroku PaaS as hosting for app.
  • Firebase API as database for user preferences and in-app data validation.
  • exceljs for parsing and generating json-formatted schedule with metadata from *.xlsx file.
  • google-news-rss for parsing Google RSS feed.
  • Yandex.Metrica for statistics tracking.

To run an app on local machine:

1) Run npm i to install all dependencies.
2) Add an .env file in root directory with following fields:
  • PORT={Port you want to run on(etc. 5000)}
  • BOT_TOKEN={Your Telegram token}
  • METRICA_TOKEN={Your Yandex AppMetrica token}
  • FIREBASE_USERS_URL={Your Firebase_Users URL}
  • FIREBASE_USERS_PROJECT_ID={Your Firebase_Users project ID}
  • FIREBASE_USERS_CLIENT_EMAIL={Your Firebase_Users client email}
  • FIREBASE_USERS_PRIVATE_KEY={Your Firebase_Users private key}
3) Run node . to run the server in Long Polling mode.

How to deploy an app on Heroku:

1) Create an app on Heroku.
2) Configure local variables by heroku-cli after push:
  • heroku config:set BOT_TOKEN={Your Telegram token}
  • heroku config:set METRICA_TOKEN={Your Yandex AppMetrica token}
  • heroku config:set HEROKU_URL={Your Heroku URL}
  • heroku config:set FIREBASE_USERS_URL={YourFirebaseUsersURL}
  • heroku config:set FIREBASE_USERS_PROJECT_ID={Your Firebase_Users project ID}
  • heroku config:set FIREBASE_USERS_CLIENT_EMAIL={Your Firebase_Users client email}
  • heroku config:set FIREBASE_USERS_URL={Your Firebase_Users private key}
3) Commit and push to Heroku:
  • git add .
  • git commit -m "init deploy commit"
  • git push heroku master
4) Scale an app with heroku-cli to run it with Webhook:
  • heroku login -> enter your credentials
  • heroku ps:scale web=1 -a {YourAppName} -> to start dyno
  • heroku ps:scale web=0 -a {YourAppName} -> to shut down dyno

How to make a contribution:

1) Run npm run lint and correct all typos.
2) Push to development branch with:
  • git add .
  • git commit -m "feature/fix commit"
  • git push origin HEAD:develop
3) Create pull request.

User interface:

Graphical User Interface

Yandex.Metrica example stats:

Yandex.Metrica stats 1 Yandex.Metrica stats 2

Tests:

https://github.com/oauthjs/express-oauth-server/blob/master/test/integration/index_test.js https://github.com/oauthjs/express-oauth-server/blob/master/test/unit/index_test.js

TODO:

  • Правильный хендл всех ошибок про асинхронщину (async/await)

Обязательно используем Node.js v14 (хипдамп может не собраться) Разработка из-под впн (vpnbook) jupyter lab (не notebook)