예제 #1
0
from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioPiped

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
audio_file = 'input.webm'
call_py.join_group_call(
    -1001234567890,
    AudioPiped(audio_file, ),
    stream_type=StreamType().pulse_stream,
)
idle()
from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioVideoPiped
from pytgcalls.types.input_stream.quality import HighQualityAudio
from pytgcalls.types.input_stream.quality import HighQualityVideo

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
remote = 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4'
call_py.join_group_call(
    -1001234567890,
    AudioVideoPiped(
        remote,
        HighQualityAudio(),
        HighQualityVideo(),

        # You can add --video or --audio to the ffmpeg
        # command line to specify to what you want to add these parameters
        additional_ffmpeg_parameters='EVERYTHING BEFORE THE INPUT (-i) '
                                     '-atmid '
                                     'EVERYTHING AFTER THE INPUT (-i) '
                                     '-atend '
예제 #3
0
            # CHANGE THIS BASED ON WHAT YOU WANT
            'best[height<=?720][width<=?1280]',
            'https://www.youtube.com/watch?v=msiLgFkXvD8',
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
        )
        stdout, stderr = await proc.communicate()
        return stdout.decode().split('\n')[0]
    return asyncio.get_event_loop().run_until_complete(run_async())


app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
remote = get_youtube_stream()
call_py.join_group_call(
    -1001234567890,
    AudioVideoPiped(
        remote,
        HighQualityAudio(),
        HighQualityVideo(),
    ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #4
0
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
예제 #5
0
from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioPiped

app = Client(
    'py-tgcalls',
    api_id=12345,
    api_hash='0123456789abcdef0123456789abcdef',
)

call_py = PyTgCalls(app)
chat_id = -1001234567890
call_py.start()
audio_file = 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4'
call_py.join_group_call(
    chat_id,
    AudioPiped(audio_file, ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #6
0
# 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
예제 #7
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'))
예제 #8
0
import os
import time

from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import InputAudioStream
from pytgcalls.types.input_stream import InputStream

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
file = '../input.raw'
while not os.path.exists(file):
    time.sleep(0.125)
call_py.join_group_call(
    -1001234567890,
    InputStream(InputAudioStream(file, ), ),
    stream_type=StreamType().local_stream,
)
idle()
예제 #9
0
from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioImagePiped
from pytgcalls.types.input_stream.quality import HighQualityVideo

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
audio_file = 'input.webm'
call_py.join_group_call(
    -1001234567890,
    AudioImagePiped(
        audio_file,
        'test.png',
        video_parameters=HighQualityVideo(),
    ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #10
0
from pyrogram import filters
from pyrogram.types import Message

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types import Update
from pytgcalls.types.input_stream import InputAudioStream
from pytgcalls.types.input_stream import InputStream

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)
call_py = PyTgCalls(app)


@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)
    await call_py.join_group_call(
        message.chat.id,
        InputStream(
            InputAudioStream(
                file,
            ),
        ),
        stream_type=StreamType().local_stream,
예제 #11
0
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
예제 #12
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,
    )

예제 #13
0
# '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)
from pyrogram import Client

from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioVideoPiped
from pytgcalls.types.input_stream.quality import HighQualityAudio
from pytgcalls.types.input_stream.quality import HighQualityVideo

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
remote = 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4'
call_py.join_group_call(
    -1001234567890,
    AudioVideoPiped(
        remote,
        HighQualityAudio(),
        HighQualityVideo(),
        additional_ffmpeg_parameters='EVERYTHING BEFORE THE INPUT (-i) '
        '-atend '
        'EVERYTHING AFTER ALL ARGUMENTS',
    ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #15
0
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 CaptureVideoDesktop

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
call_py.join_group_call(
    -1001234567890,
    CaptureVideoDesktop(
        MediaDevices.get_screen_devices()[0],
    ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #16
0
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"])
예제 #17
0
#!/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)
예제 #18
0
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)
예제 #19
0
from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioParameters
from pytgcalls.types.input_stream import InputAudioStream
from pytgcalls.types.input_stream import InputStream
from pytgcalls.types.input_stream import InputVideoStream
from pytgcalls.types.input_stream import VideoParameters

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
audio_file = 'audio.raw'
video_file = 'video.raw'
while not os.path.exists(audio_file) or \
        not os.path.exists(video_file):
    time.sleep(0.125)
call_py.join_group_call(
    -1001234567890,
    InputStream(
        InputAudioStream(
            audio_file,
            AudioParameters(bitrate=48000, ),
        ),
        InputVideoStream(
            video_file,
예제 #20
0
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
예제 #21
0
from pytgcalls import idle
from pytgcalls import PyTgCalls
from pytgcalls import StreamType
from pytgcalls.types import Browsers
from pytgcalls.types.input_stream import AudioVideoPiped
from pytgcalls.types.input_stream.quality import HighQualityAudio
from pytgcalls.types.input_stream.quality import HighQualityVideo

app = Client(
    'py-tgcalls',
    api_id=123456789,
    api_hash='abcdef12345',
)

call_py = PyTgCalls(app)
call_py.start()
remote = 'http://docs.evostream.com/sample_content/assets/sintel1m720p.mp4'
call_py.join_group_call(
    -1001234567890,
    AudioVideoPiped(
        remote,
        HighQualityAudio(),
        HighQualityVideo(),
        headers={
            'User-Agent': Browsers().chrome_windows,
        },
    ),
    stream_type=StreamType().pulse_stream,
)
idle()
예제 #22
0
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()
예제 #23
0
    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)