Telegram Voice Chat UserBot made with Pyrogram and MarshalX/tgcalls with playlist and Heroku support

Overview

Telegram Voice Chat UserBot

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

It's recommended to use tgmusicbot along with this userbot.

Deploy to Heroku

Deploy

  • 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.

Introduction

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

  1. Start the userbot
  2. 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)
  3. 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.
  4. 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

Requirements

  • 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

Run

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.

Method 1: use config.ini

Create a config.ini file

[pyrogram]
api_id = 1234567
api_hash = 0123456789abcdef0123456789abcdef

[plugins]
root = plugins
include =
    vc.player
    ping
    sysinfo

Method 2: write your own userbot.py

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')

Notes

  • Read module docstrings of plugins/ you are going to use at the beginning of the file for extra notes

License

AGPL-3.0-or-later

Comments
  • Not run when i send !join

    Not run when i send !join

    when i send !join ,it only will quit voice chat a few seconds after joining and will print this on console 'GroupCall' object has no attribute 'params' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/pyrogram/dispatcher.py", line 222, in handler_worker await handler.callback(self.client, *args) File "/usr/local/lib/python3.9/dist-packages/pytgcalls/mtproto/pyrogram_bridge.py", line 63, in _process_update await self._update_to_handler[type(update)](update) File "/usr/local/lib/python3.9/dist-packages/pytgcalls/mtproto/pyrogram_bridge.py", line 75, in _process_group_call_update call = GroupCallWrapper(update.call.id, update.call.params) AttributeError: 'GroupCall' object has no attribute 'params'

    opened by mengxin239 2
  • Heroku buffer size error

    Heroku buffer size error

    2021-04-09T15:41:02.326210+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyrogram/storage/memory_storage.py", line 38, in open 2021-04-09T15:41:02.326379+00:00 app[worker.1]: dc_id, test_mode, auth_key, user_id, is_bot = struct.unpack( 2021-04-09T15:41:02.326416+00:00 app[worker.1]: struct.error: unpack requires a buffer of 263 bytes 2021-04-09T15:41:02.516189+00:00 heroku[worker.1]: Process exited with status 1 2021-04-09T15:41:02.587150+00:00 heroku[worker.1]: State changed from up to crashed

    opened by TharushaT 2
  • AttributeError: can't set attribute

    AttributeError: can't set attribute

    When I executed !join, he got the following error:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/pyrogram/dispatcher.py", line 217, in handler_worker
        await handler.callback(self.client, *args)
      File "/root/tgvc-userbot/plugins/vc/player.py", line 297, in join_group_call
        group_call.client = client
    AttributeError: can't set attribute
    

    This is my logs:

    root@ip-172-31-40-61:~/tgvc-userbot# python3 userbot.py 
    Pyrogram v1.2.9, Copyright (C) 2017-2021 Dan <https://github.com/delivrance>
    Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
    
    tgcalls v1.0.0, Copyright (C) 2020-2021 Il`ya (Marshal) <https://github.com/MarshalX>
    Licensed under the terms of the GNU Lesser General Public License v3 (LGPLv3) 
    
    
    >>> USERBOT STARTED
    can't set attribute
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/pyrogram/dispatcher.py", line 217, in handler_worker
        await handler.callback(self.client, *args)
      File "/root/tgvc-userbot/plugins/vc/player.py", line 296, in join_group_call
        group_call.client = client
    AttributeError: can't set attribute
    
    bug 
    opened by LovelyHaochi 1
  • Remove Railway Button

    Remove Railway Button

    Hey, Railway Founder here

    Sadly tgvc violates Railway's ToS. We've got mechanisms to automagically report users to the relevant authorities with any information we collect, but the interest of not having unknowing parties get in trouble, removing this button from the repo

    Thanks again

    opened by JakeCooper 1
  • error after join voice chat

    error after join voice chat

    After joining the vc this appears on the console. Commands like !ping, !uptime keep working but don't play music.

    USERBOT STARTED Task exception was never retrieved future: <Task finished name='Task-110' coro=<network_status_changed_handler() done, defined at /home/ubuntu/tgvc-userbot/utils/vc.py:123> exception=ValueError('Peer id invalid: -100525701833')> Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/pyrogram/methods/advanced/resolve_peer.py", line 60, in resolve_peer return await self.storage.get_peer_by_id(peer_id) File "/usr/local/lib/python3.8/dist-packages/pyrogram/storage/sqlite_storage.py", line 147, in get_peer_by_id raise KeyError(f"ID not found: {peer_id}") KeyError: 'ID not found: -100525701833'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/home/ubuntu/tgvc-userbot/utils/vc.py", line 127, in network_status_changed_handler await mp.send_text(f"{emoji.CHECK_MARK_BUTTON} joined the voice chat") File "/home/ubuntu/tgvc-userbot/utils/vc.py", line 92, in send_text message = await client.send_message( File "/usr/local/lib/python3.8/dist-packages/pyrogram/methods/messages/send_message.py", line 127, in send_message peer=await self.resolve_peer(chat_id), File "/usr/local/lib/python3.8/dist-packages/pyrogram/methods/advanced/resolve_peer.py", line 87, in resolve_peer peer_type = utils.get_peer_type(peer_id) File "/usr/local/lib/python3.8/dist-packages/pyrogram/utils.py", line 203, in get_peer_type raise ValueError(f"Peer id invalid: {peer_id}") ValueError: Peer id invalid: -100525701833

    opened by Jroddmqz 1
  • Error in running with userbot.py

    Error in running with userbot.py

    Hi. When I want to run the bot with userbot.py with command sudo python3.8 userbot.py it returns error: [tgvc] [LOAD] Ignoring non-existent module "plugins.vc.player" [tgvc] [LOAD] Ignoring non-existent module "plugins.sysinfo" >>> USERBOT STARTED It seems that the bot can't import two plugins, but ping plugin works completely and without error. I used the examples that you wrote in readme file for config.ini file and I'm sure that all information sets carefully. I really appreciate it if someone could help me.

    opened by GoldExynos 1
  • Floodwait Sleep Error

    Floodwait Sleep Error

    Facing floodwait sleep error in userbot logs if multiple songs like 10 files added simultaneously in chat by forwarding them. Please fix it if possible, by tweaking it's sleep time or new song file fetching logic.

    bug enhancement 
    opened by whoogle 1
Owner
Calls Music
A team of developers focusing on Telegram group call-related projects.
Calls Music
Free and Open Source Channel/Group Voice chat music player for telegram ❤️ with button support Heroku Commands

ZeusMusic Requirements ?? FFmpeg NodeJS nodesource.com Python 3.7 or higher PyTgCalls MongoDB 2nd Telegram Account (needed for userbot) ?? Get SESSION

ZeusNetwork 4 Jan 3, 2022
Telegram bot for stream music on telegram, powered by py-tgcalls and Pyrogram

Telegram Streamer Bot Telegram bot for stream music on telegram, powered by py-tgcalls and Pyrogram ✨ Features Coming soon, help me to improve it ?? C

Shohih Abdul 11 Oct 21, 2022
TgMusicBot is a telegram userbot for playing songs in telegram voice calls based on Pyrogram and PyTgCalls.

TgMusicBot [Stable] TgMusicBot is a telegram userbot for playing songs in telegram voice calls based on Pyrogram and PyTgCalls. Commands !start / !hel

Kürşad 21 Dec 25, 2022
Rocks vc Userbot: A Telegram Bot Project That's Allow You To Play Audio And Video Music On Telegram Voice Chat Group

⭐️ Rocks VC Userbot ⭐️ Telegram Userbot To Play Audio And Video Song On VC Chat

Dr Asad Ali 10 Jul 18, 2022
Telegram Group Calls Streaming bot with some useful features, written in Python with Pyrogram and Py-Tgcalls. Supporting platforms like Youtube, Spotify, Resso, AppleMusic, Soundcloud and M3u8 Links.

Yukki Music Bot Yukki Music Bot is a Powerful Telegram Music+Video Bot written in Python using Pyrogram and Py-Tgcalls by which you can stream songs,

Team Yukki 996 Dec 28, 2022
A Telegram Music Bot with proper functions written in Python with Pyrogram and Py-Tgcalls.

⭐️ Yukki Music Bot ⭐️ A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls Ready to use method A Support Group and ready-to-use runnin

Shikhar Kumar 1000 Jan 3, 2023
A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls

A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls. This is Also The Source Code of The UserBot Which is Playing Music in @S1-BOTS Support Group ❤️

SAF ONE 224 Dec 28, 2022
ShadowMusic - A Telegram Music Bot with proper functions written in Python with Pyrogram and Py-Tgcalls.

⭐️ Shadow Music ⭐️ A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls Ready to use method A Support Group, Updates Channel and ready

TeamShadow 8 Aug 17, 2022
Ini adalah UserBot Telegram dengan banyak modul keren. Ditulis dengan Python dengan Telethon dan Py-Tgcalls.

Okaeri-Userbot Okaeri-Userbot = userbot telegram modular yang berjalan di python3 dengan database sqlalchemy. Disclaimer Saya tidak bertanggung jawab

Wahyu 1 Dec 15, 2021
A Telegram UserBot to Play Radio in Voice Chats. This is also the source code of the userbot which is being used for playing Radio in @AsmSafone Channel.

Telegram Radio Player UserBot A Telegram UserBot to Play Radio in Channel or Group Voice Chats. This is also the source code of the userbot which is b

SAF ONE 44 Nov 12, 2022
Free and Open Source Group Voice chat music player for telegram ❤️ with button support youtube playback support

Free and Open Source Group Voice chat music player for telegram ❤️ with button support youtube playback support

Sehath Perera 1 Jan 8, 2022
Minimal telegram voice chat music bot, in pyrogram.

VCBOT Fully working VC (user)Bot, based on py-tgcalls and py-tgcalls-wrapper with minimal features. Deploying To heroku: Local machine/VPS: git clone

Aditya 33 Nov 12, 2022
The Best Telegram UserBot Made With Pyrogram [Python]

Asterix UserBot A Powerful Telegram userbot based on Pyrogram. How To Deploy Asterix Heroku Railway Qovery Termux Tutorial Railway Deploy Comming Soon

TeamAsterix 9 Oct 17, 2022
Latest Open Source Code for Playing Music in Telegram Video Chat. Made with Pyrogram and Pytgcalls 💖

MusicPlayer_TG Latest Open Source Code for Playing Music in Telegram Video Chat. Made with Pyrogram and Pytgcalls ?? Requirements ?? FFmpeg NodeJS nod

Abhijith Sudhakaran 2 Feb 4, 2022
A Telegram Userbot to play or streaming Audio and Video songs / files in Telegram Voice Chats.

Vcmusic-Userbot A Telegram Userbot to play or streaming Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram R

null 3 Oct 23, 2021
A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats.

VC UserBot A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram Requirements Python

조던 1 Nov 29, 2021
A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats

TG-MusicPlayer A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram Requirements Py

null 4 Jul 30, 2022
Telegram Group Manager Bot + Userbot Written In Python Using Pyrogram.

Telegram Group Manager Bot + Userbot Written In Python Using PyrogramTelegram Group Manager Bot + Userbot Written In Python Using Pyrogram

null 1 Nov 11, 2021
ZELDA USERBOT adalah userbot Telegram modular yang berjalan di Python3 dengan database sqlalchemy.

ZELDA USERBOT TELEGRAM Userbot Yang Di Buat Karena Sering Gabut Di Telegram. ZELDA USERBOT adalah userbot Telegram modular yang berjalan di Python3 de

null 1 Dec 23, 2021