from pyrogram import Client from pytgcalls import idle from pytgcalls import PyTgCalls from pytgcalls import StreamType from pytgcalls.media_devices import MediaDevices from pytgcalls.types import CaptureAudioDevice app = Client( 'py-tgcalls', api_id=123456789, api_hash='abcdef12345', ) call_py = PyTgCalls(app) call_py.start() call_py.join_group_call( -1001234567890, CaptureAudioDevice(MediaDevices.get_audio_devices()[0], ), stream_type=StreamType().pulse_stream, ) idle()
from pyrogram import Client from pytgcalls import PyTgCalls import sira import config client = Client(config.SESSION_NAME, config.API_ID, config.API_HASH) pytgcalls = PyTgCalls(client, 1512, False) @pytgcalls.on_stream_end() def on_stream_end(chat_id: int) -> None: sira.task_done(chat_id) if sira.is_empty(chat_id): pytgcalls.leave_group_call(chat_id) else: pytgcalls.change_stream(chat_id, sira.get(chat_id)["file_path"]) run = pytgcalls.run
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. from pyrogram import Client from pytgcalls import PyTgCalls from CodentsMusic.config import API_HASH, API_ID, SESSION_NAME from CodentsMusic.services.callsmusic import queues client = Client(SESSION_NAME, API_ID, API_HASH) pytgcalls = PyTgCalls(client) @pytgcalls.on_stream_end() def on_stream_end(chat_id: int) -> None: queues.task_done(chat_id) if queues.is_empty(chat_id): pytgcalls.leave_group_call(chat_id) else: pytgcalls.change_stream(chat_id, queues.get(chat_id)["file"]) run = pytgcalls.run
from pyrogram import Client from pytgcalls import PyTgCalls from sira import is_empty, get, task_done import config client = Client(config.SESSION_NAME, config.API_ID, config.API_HASH) pytgcalls = PyTgCalls(1512, False) playing = [] @pytgcalls.on_event_update() def _(update: dict) -> None: if update["result"] == "JOINED_VOICE_CHAT": if update["chat_id"] not in playing: playing.append(update["chat_id"]) @pytgcalls.on_stream_end() def on_stream_end(chat_id: int) -> None: task_done(chat_id) if chat_id in playing: playing.remove(chat_id) if is_empty(chat_id): pytgcalls.leave_group_call(chat_id) else: pytgcalls.change_stream(chat_id, get(chat_id)["file_path"])
from pyrogram import Client as TelegramClient from pytgcalls import PyTgCalls from config import SESSION_NAME, API_ID, API_HASH telegram_client = TelegramClient(SESSION_NAME, API_ID, API_HASH) pytgcalls = PyTgCalls() open("server.env", "w+").write("\n".join( f"{k}={v!r}" for k, v in { "HOST": pytgcalls._host, "PORT": pytgcalls._port, "SESSION_ID": pytgcalls._session_id }.items())) pytgcalls.run(telegram_client)
#!/usr/bin/env python3 # Copyright (C) @subinps # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. from pytgcalls import PyTgCalls from pyrogram import Client from config import Config from utils import LOGGER USER = Client(Config.SESSION, Config.API_ID, Config.API_HASH, plugins=dict(root="userplugins")) group_call = PyTgCalls(USER, cache_duration=180)
from pytgcalls.types import (Update, StreamAudioEnded, JoinedGroupCallParticipant, LeftGroupCallParticipant) from pytgcalls.types.input_stream import (AudioVideoPiped, AudioPiped, VideoParameters) from userge import userge, Message, pool, filters, get_collection, config from .. import video_chat from userge.utils import time_formatter, progress, runcmd, is_url, get_custom_import_re from userge.utils.exceptions import StopConversation ytdl = get_custom_import_re(video_chat.YTDL_PATH) # https://github.com/pytgcalls/pytgcalls/blob/master/pytgcalls/mtproto/mtproto_client.py#L18 userge.__class__.__module__ = 'pyrogram.client' call = PyTgCalls(userge, overload_quiet_mode=True) call._env_checker.check_environment() # pylint: disable=protected-access CHANNEL = userge.getCLogger(__name__) LOG = userge.getLogger() VC_DB = get_collection("VC_CMDS_TOGGLE") CMDS_FOR_ALL = False GROUP_CALL_PARTICIPANTS: List[int] = [] ADMINS = {} PLAYING = False CHAT_NAME = "" CHAT_ID = 0
from pyrogram import Client from pyrogram import filters from pyrogram.types import Message from pytgcalls import PyLogs from pytgcalls import PyTgCalls from pytgcalls import StreamType app = Client( 'py-tgcalls', api_id=123456789, api_hash='abcdef12345', ) call_py = PyTgCalls( app, log_mode=PyLogs.ultra_verbose, ) if __name__ == '__main__': @app.on_message(filters.regex('!play')) async def play_handler(client: Client, message: Message): file = 'input.raw' while not os.path.exists(file): await asyncio.sleep(0.125) call_py.join_group_call( message.chat.id, file, stream_type=StreamType().local_stream, ) @app.on_message(filters.regex('!change_stream'))
YTDL_PATH = os.environ.get("YOUTUBE_DL_PATH", "yt_dlp") MAX_DURATION = int(os.environ.get("MAX_DURATION", 900)) VC_SESSION = secured_env("VC_SESSION_STRING") if VC_SESSION: VC_CLIENT = Client("usergeMusic", config.API_ID, config.API_HASH, session_string=VC_SESSION) VC_CLIENT.storage.session_string = VC_SESSION else: userge.__class__.__module__ = 'pyrogram.client' VC_CLIENT = userge call = PyTgCalls(VC_CLIENT, overload_quiet_mode=True) call._env_checker.check_environment() # pylint: disable=protected-access CHANNEL = userge.getCLogger(__name__) LOG = userge.getLogger() CURRENT_SONG = {} CONTROL_CHAT_IDS: List[int] = [] CQ_MSG: List[RawMessage] = [] QUEUE: List[Union[TgResource, UrlResource]] = [] GROUP_CALL_PARTICIPANTS: List[int] = [] class Vars: CHAT_NAME = "" CHAT_ID = 0
from pytgcalls.types.input_stream import InputAudioStream from pytgcalls.types.input_stream import InputStream app = Client( 'py-tgcalls', api_id=123456789, api_hash='abcdef12345', ) app2 = Client( 'py-tgcalls', api_id=123456789, api_hash='abcdef12345', ) # You can enter an unlimited number of PyTgCalls clients call_py = PyTgCalls(app) call_py2 = PyTgCalls(app2) @app.on_message(filters.regex('!p1')) async def play_handler(client: Client, message: Message): file = '../input.raw' while not os.path.exists(file): time.sleep(0.125) await call_py.join_group_call( message.chat.id, InputStream(InputAudioStream(file, ), ), stream_type=StreamType().local_stream, )
# 'bot' variable if STRING_SESSION: session = StringSession(str(STRING_SESSION)) else: session = "ManUserBot" try: bot = TelegramClient( session=session, api_id=API_KEY, api_hash=API_HASH, connection=ConnectionTcpAbridged, auto_reconnect=True, connection_retries=None, ) call_py = PyTgCalls(bot) except Exception as e: print(f"STRING_SESSION - {e}") sys.exit() if STRING_2: session2 = StringSession(str(STRING_2)) MAN2 = TelegramClient( session=session2, api_id=API_KEY, api_hash=API_HASH, connection=ConnectionTcpAbridged, auto_reconnect=True, connection_retries=None, ) call_py2 = PyTgCalls(MAN2)
session = StringSession(str(STRING_SESSION)) else: session = "ManUserBot" try: bot = TelegramClient( session=session, api_id=API_KEY, api_hash=API_HASH, connection=ConnectionTcpAbridged, auto_reconnect=True, connection_retries=None, ) except Exception as e: print(f"STRING_SESSION - {e}") sys.exit() call_py = PyTgCalls(bot) async def check_botlog_chatid(): if not BOTLOG_CHATID and LOGSPAMMER: LOGS.info( "Anda harus menambahkan var BOTLOG_CHATID di config.env atau di var heroku, agar penyimpanan log error userbot pribadi berfungsi." ) sys.exit(1) elif not BOTLOG_CHATID and BOTLOG: LOGS.info( "Anda harus menambahkan var BOTLOG_CHATID di config.env atau di var heroku, agar fitur logging userbot berfungsi." ) sys.exit(1)