Preface#
Can you help me write?
Important
The behavior of UserBot may be abused by Telegram officials, please consider the potential risks carefully.
Preparation#
- Telegram Bot Token
- Telegram API Key
- Telegram account
- One server (recommended 2c2g)
Note
Please select the DC location for Player and Bot based on the location of your server, otherwise it may result in a poor experience.
- One smart brain
- One nimble hand
Environment Preparation#
- Ubuntu Server 22.04
- MongoDB 7.0
- Python 3.9
Environment Installation#
MongoDB#
Please refer to the MongoDB official website for installation. After installation, you need to manually start it.
systemctl start mongod
systemctl enable mongod
Python#
Please refer to the internet search engines such as Baidu, Google, Bing, Sogou, and 360 to install Python on Ubuntu 20.04.
Obtain TG API Key#
As mentioned before, directly refer to the previous tutorial to obtain the API ID and API Hash.
Note
If you already have the API ID and API Hash, please skip this step.
First, open the Telegram official website.
Enter the phone number associated with your Telegram account (in international format, such as +8618911451919).
Then enter the received verification code to log in.
Then click on API development tools
.
Then come to this page and fill in the information as required.
Then we will get this string.
Take note of it and we will use it later.
Note
If an ERROR pops up when clicking on Create application, it may be because you are unlucky. It is recommended to try changing nodes or devices. If it still doesn't work, you can directly beg others for help. (When I wrote the tutorial in August 2022, APIs could be easily obtained. I tried two accounts today and still couldn't get it wwwww)
Start Installation#
Obtain#
First, clone the repository.
git clone https://github.com/TeamYukki/YukkiMusicBot.git
cd YukkiMusicBot
Accounts#
Here, you need a Bot and a normal Telegram account.
Add them to the same group as the log group and set them both as administrators (full control is sufficient), then note down the group ID (with -100).
Then, in this group, turn on video chat (just turn it on and exit, do not click on end).
Obtain String Session#
Find @MaybexSessionBot.
After entering, click on Pyrogram
.
Then enter your API ID and API HASH as prompted.
Then enter the phone number of the prepared account.
Then you will receive a verification code.
When sending the code, leave a space before the code.
After this appears, it means it is successful.
Open the "Saved Message" of the account and note down this string. We will use it later.
Configuration#
Go back to the server.
cp sample.env .env
Open .env
with your favorite editor.
Then fill in the information according to my comments.
After filling in, save and exit.
Of course, you can also fill in the Spotify API according to this.
More parameters can be found here.
Installation#
cp .env .env.bak
./setup
Answer y and press Enter when prompted.
When you reach this step, press Ctrl + C
.
After completion, enter the following command.
rm .env
cp .env.bak .env
Then enter ./start
to start!
If you see this, it means it has started successfully. You can use screen or similar tools to keep it running persistently.
By the way, if you encounter an error after stopping the Bot with Ctrl + C,
delete YukkiMusicBot.session
and run it again.
Try it out now!
Conclusion#
In addition, here is a list of reference commands (you can set Bot Commands in BotFather).
start - Start
play - Play music
vplay - Play video
cplay - Play in all channels
playlist - Playlist
skip - Skip the current song
stop - Stop playing
loop - Loop (number of times)
ping - Are you alive?
speedtest - One-click show off (only for Sudo users)
reboot - Reboot (only for Sudo users)
This concludes the tutorial. If it is helpful to you, feel free to share it with others.