Simple Node.js program that changes emoji status from "Work" to "Sleep" and back depending on time and day of week.
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.
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.
- Clone this repository
- Install all dependencies (first install Node.js and npm if you don't have it)
- Build with SWC using
npm run build
- Fill .env file using example below
- Setup with
npm run start -- --interactive
(note both--
), follow instructions in interactive prompt - 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
Must be in project's root (not in src, not in out dirs)
API_ID=
API_HASH=
Obtain these secrets on my.telegram.org
Made in one hour, now get me a job.