Skip to content

A telegram bot to update your bio with music playing on your android phone in real time!

License

Notifications You must be signed in to change notification settings

BlessonTG/ongaku

 
 

Repository files navigation

Ongaku

A smol and fluffy telegram bot to update your bio with music playing on your android phone in real time!

Requirements

  • An android device capable of running Termux
  • A music player app capable of showing notifications of current music being played

Getting started

  • Install Termux and Termux:API apps from F-Droid.
  • Launch Termux and run the following commands
apt update && apt dist-upgrade -y && apt update && apt install -y git nano python termux-api && git clone https://github.com/gibcheesepuffs/ongaku --depth=1 && cd ongaku && pip install virtualenv && virtualenv venv && source venv/bin/activate
pip install -r requirements.txt && deactivate && cd .. && termux-notification-list

You will be asked to provide notification access to Termux:API app. You must provide Termux:API app all the required permissions. You may be required to do Ctrl+C to continue.

  • When you run the Ongaku for the first time you are asked to enter your phone number to create a session. Ongaku uses this session to work with your telegram account.

  • Create a config.env file from sample-config.env

$ cd ongaku && cp sample-config.env config.env

Edit config.env as instructed by the file itself.

$ nano config.env

  • You can get API_ID and API_HASH from here.

  • You can use this app to check package name of your music player app and add it to MUSIC_PLAYER value.

  • To optionally get LOG_CHANNEL create a private telegram channel and send a random message in it. After that forward that message to @username_to_id_bot on telegram or here.

  • You can leave out STRING_SESSION for now by uncommenting it.

  • Starting IDBot on telegram will also give you your own ID. Put that in USERS value.

Use Ctrl+X to exit and save your changes.

  • Run ./launch inside ongaku directory. You will receive your STRING_SESSION in your saved messages in telegram app.

  • Copy the session text and edit your config.env file once again by running nano config.env

  • Paste your session text according to the instructions in the file.

Use Ctrl+X to exit and save your changes.

  • Run ./launch inside ongaku directory once again.

  • If this is your first time launching Ongaku then you will be asked to enter your phone number to login. Next launches will work without having to re-login.

  • If everything went well you should be up and running. At this point you can start playing music and you should see current playing song in the Termux app and in the telegram channel you set for logging if any.

  • From notifications tap on ACQUIRE WAKELOCK on termux notification and allow access to let Termux run in background. This needs to be done each time you relaunch termux.

Tips

  • If you frequently switch between multiple music players, you may want to keep multiple config.env files. You can make any number of .env files named like config-1.env, config-2.env, config-3.env... and so on. To keep any one the file active at one time, you just have to rename that file to config.env and use launch script as usual.

Known Limitations

  • Ongaku cannot yet differentiate between the states of music player itself i.e. Playing, Paused and Stopped. It simply assumes existing music player notification as a Playing state.
  • It is not yet possible to run Ongaku on a baremetal server or a VPS/PaaS such as Heroku.
  • Devices running MIUI are unsupported as Xiaomi loves to revoke notification permission after X amount of hours and even at each device reboot. However you can still use Ongaku if you are willing to provide notification access manually from Settings app each time Ongaku starts malfunctioning! This is something you can also fix by running a reputable custom rom such as LineageOS. (#RipBozo 💯🤣🤣 if you choose to run MIUI on your phone anyway)

Optional commands

Send in any telegram chat

.about to view info about the project.

.history to get list of music played in current session.

.sync to force sync bio with latest notification.

Authors

Support

Shouko's Lab

About

A telegram bot to update your bio with music playing on your android phone in real time!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 85.6%
  • Shell 14.4%