Skip to content

Simple Node.js program that changes emoji status from "Work" to "Sleep" and back depending on time and day of week.

License

Notifications You must be signed in to change notification settings

VityaSchel/hloth-telegram-status

Repository files navigation

Telegram Emoji Status bot

image image image

Simple Node.js program that changes emoji status from "Work" to "Sleep" and back depending on time and day of week.

About this project

Built with 3 statuses in mind:

  • Work: from 15 until 22 every weekday relative to Russia, Samara timezone
  • Sleep: from 0 until 15 and from 22 until 0 every weekday relative to the same timezone
  • AFK: full weekend

Emojis are taken from default «Bubbles Emoji» emoji set.

All these settings can be adjusted in src/status.ts.

Works if you have Telegram Premium subscription.

Technical details

Works on gram.js, stores session as local files (.telegram_session directory).

Tested with Jest, covers only status determination function.

Initialized with my personal bootstrapping tool Scaffold.

TypeScript, SWC, Babel used in this project are self-explanatory.

Install & setup

  1. Clone this repository
  2. Install all dependencies (first install Node.js and npm if you don't have it)
  3. Build with SWC using npm run build
  4. Fill .env file using example below
  5. Setup with npm run start -- --interactive (note both --), follow instructions in interactive prompt
  6. Add cronjob to execute this script every few hours, see examples below

Warning Make sure to replace path to Node.js with yours. Use this command to get Node.js executable path: which node. Also replace path to this repository, this path is for demonstration purposes and you will likely have different directory.

You can use any frequency you like, but I prefer every hour:

0 * * * * /usr/bin/node /path/to/repo/out/index.js

Every two hours:

0 */2 * * * /usr/bin/node /path/to/repo/out/index.js

Every ½ hour:

*/30 * * * * /usr/bin/node /path/to/repo/out/index.js

And so on...

.env file

Must be in project's root (not in src, not in out dirs)

API_ID=
API_HASH=

Obtain these secrets on my.telegram.org

LICENSE

MIT

Funding

Made in one hour, now get me a job.

About

Simple Node.js program that changes emoji status from "Work" to "Sleep" and back depending on time and day of week.

Topics

Resources

License

Stars

Watchers

Forks