A Telegram UserBot to Play Audio in Voice Chats.
This is also the source code of the userbot which is being used for playing DJ/Live Sets music in VC DJ/Live Sets group.
Made with tgcalls and Pyrogram Smart Plugin
- Session string can be exported by using Pyrogram
# pip install Pyrogram TgCrypto from pyrogram import Client api_id = 1234567 api_hash = "0123456789abcdef0123456789abcdef" with Client(":memory:", api_id, api_hash) as app, open("session.txt", "w+") as s_file: session_string = app.export_session_string() s_file.write(session_string) print("Session string has been saved to session.txt") print(session_string)
- Enable the worker after deploy the project to Heroku
- Send
!join
to a voice chat enabled group chat from userbot account itself or its contacts - Reply to an audio with
/play
to start playing it in the voice chat, every member of the group can use the!play
and other common commands now, check!help
for more commands
There are some other branchs for other plugins, you can press the "Deploy to Heroku" button there to deploy it as well.
Features
- Playlist, queue
- Loop one track when there is only one track in the playlist
- Automatically downloads audio for the first two tracks in the playlist to ensure smooth playing
- Automatically pin the current playing track
- Show current playing position of the audio
How to Use the Player plugin
- Start the userbot
- send
!join
to a voice chat enabled group chat from userbot account itself or its contacts, be sure to make the userbot account as group admin and give it at least the following permissions:- Delete messages
- Manage voice chats (optional)
- reply to an audio with
/play
to start playing it in the voice chat, every member of the group can use common commands such like/play
,/current
and!help
now. - check
!help
for more commands
Commands
The main plugin is vc.player
which has the following command commands and admin commands.
After start the bot, send !join
to a voice chat enabeld group chat from userbot account
itself or its contacts, and then common commands like /play
and /current
will be available
to every member of the group. send !help
to check more commands.
- Common commands, available to group members of current voice chat
- starts with / (slash) or ! (exclamation mark)
Common Commands | Description |
---|---|
/play | reply with an audio to play/queue it, or show playlist |
/current | show current playing time of current track |
/repo | show git repository of the userbot |
!help | show help for commands |
- Admin commands, available to userbot account itself and its contacts
- starts with ! (exclamation mark)
Admin Commands | Description |
---|---|
!skip [n] ... | skip current or n where n >= 2 |
!join | join voice chat of current group |
!leave | leave current voice chat |
!vc | check which VC is joined |
!stop | stop playing |
!replay | play from the beginning |
!clean | remove unused RAW PCM files |
!pause | pause playing |
!resume | resume playing |
!mute | mute the VC userbot |
!unmute | unmute the VC userbot |
- Commands from other plugins, available only to userbot account itself
Plugin | Commands | Description |
---|---|---|
ping | !ping | show ping time |
uptime | !uptime | show userbot uptime |
sysinfo | !sysinfo | show system info |
- Python 3.6 or higher
- A Telegram API key and a Telegram account
- Choose plugins you need, install dependencies which listed above and run
pip install -U -r requirements.txt
to install python package dependencies as well - FFmpeg
Choose one of the two methods and run the userbot with
python userbot.py
, stop with CTRL+c. The following example
assume that you were going to use vc.player
and ping
plugin, replace
api_id
, api_hash
to your own value.
Create a config.ini
file
[pyrogram]
api_id = 1234567
api_hash = 0123456789abcdef0123456789abcdef
[plugins]
root = plugins
include =
vc.player
ping
sysinfo
Replace the file content of userbot.py
from pyrogram import Client, idle
api_id = 1234567
api_hash = "0123456789abcdef0123456789abcdef"
plugins = dict(
root="plugins",
include=[
"vc.player",
"ping"
]
)
app = Client("tgvc", api_id, api_hash, plugins=plugins)
app.start()
print('>>> USERBOT STARTED')
idle()
app.stop()
print('\n>>> USERBOT STOPPED')
- Read module docstrings of plugins/ you are going to use at the beginning of the file for extra notes
AGPL-3.0-or-later