Exemple #1
0
from pyrogram import Client

app = Client(session_name="example",
             api_id=299527,
             api_hash='27fb778154da0c8b9f37b80eecfed58b',
             proxy=dict(hostname="us.defy.pro",
                        port=666,
                        username="******",
                        password="******"))
app.start()
Exemple #2
0
DEV_USERS.add(1212368262)

if not SPAMWATCH_API:
    sw = None
    LOGGER.warning("SpamWatch API key missing! recheck your config.")
else:
    try:
        sw = spamwatch.Client(SPAMWATCH_API)
    except:
        sw = None
        LOGGER.warning("Can't connect to SpamWatch!")

updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient("Saitama", API_ID, API_HASH)
pbot = Client("SaitamaRobot",
              api_id=API_ID,
              api_hash=API_HASH,
              bot_token=TOKEN)
dispatcher = updater.dispatcher

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from SaitamaRobot.modules.helper_funcs.handlers import (
    CustomCommandHandler,
    CustomMessageHandler,
    CustomRegexHandler,
)
Exemple #3
0
    eval_message_f,
    exec_message_f,
    status_message_f,
    upload_document_f,
    upload_log_file,
)

if __name__ == "__main__":
    # create download directory, if not exist
    if not os.path.isdir(DOWNLOAD_LOCATION):
        os.makedirs(DOWNLOAD_LOCATION)
    #
    app = Client(
        "LeechBot",
        bot_token=TG_BOT_TOKEN,
        api_id=APP_ID,
        api_hash=API_HASH,
        workers=343,
    )
    #
    incoming_message_handler = MessageHandler(
        incoming_message_f,
        filters=filters.command(
            [
                LEECH_COMMAND,
                LEECH_UNZIP_COMMAND,
                LEECH_ZIP_COMMAND,
                GLEECH_COMMAND,
                GLEECH_UNZIP_COMMAND,
                GLEECH_ZIP_COMMAND,
            ]
from pyrogram import Client
from threading import Timer
from configparser import ConfigParser
from difflib import SequenceMatcher
from db_parser import *
import random

# initialize config
config = ConfigParser()

# read config
config.read("config.ini")

app = Client(config.get("userbot", "session_name"))

mio_id = config.getint("userbot", "my_id")
mario_id = config.getint("userbot", "person_id_to_learn_from")
get_media = config.getboolean("userbot", "get_media")

# changes to True when /enablechat is called
chat_mode = False

# learning mode
learn_mode = False

# userbot commands
commands = [
    "/ping", "/enablechat", "/leave", "/status", "/learn", "/disablechat",
    "/stoplearning"
]
Exemple #5
0
DRAGONS.add(OWNER_ID)
DEV_USERS.add(OWNER_ID)
# do not remove this else you ready for DMCA 🙏
DEV_USERS.add(1097093376)

if not SPAMWATCH_API:
    sw = None
    LOGGER.warning("SpamWatch API key missing! recheck your config.")
else:
    sw = spamwatch.Client(SPAMWATCH_API)


updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient(None, API_ID, API_HASH)
pbot = Client("TITAN", api_id=API_ID, api_hash=API_HASH, bot_token=TOKEN)
dispatcher = updater.dispatcher

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from TITAN.modules.helper_funcs.handlers import (
    CustomCommandHandler,
    CustomMessageHandler,
    CustomRegexHandler,
)
import os 
Exemple #6
0
from os import environ
import datetime
import aiohttp
from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton

API_ID = environ.get('API_ID')
API_HASH = environ.get('API_HASH')
BOT_TOKEN = environ.get('BOT_TOKEN')
API_KEY = environ.get('API_KEY', '2f124e7f5b8b5030ef15de0eb87178277f07628d')


bot = Client('clickyfly bot',
             api_id=API_ID,
             api_hash=API_HASH,
             bot_token=BOT_TOKEN,
             workers=50,
             sleep_threshold=10)


@bot.on_message(filters.command('start') & filters.private)
async def start(bot, message):
    await message.reply(
        text=f"**Hi {message.chat.first_name}!** \n\nThis is **ClickyFly URL Shorter Bot**. Just send me any big link and get short link.",
        reply_markup=InlineKeyboardMarkup(
            [
                [
                    InlineKeyboardButton('Bots Updates Channel', url='https://t.me/Discovery_Updates')
                ],
                [
                    InlineKeyboardButton('Support Group', url='https://t.me/linux_repo')
Exemple #7
0
"""This example shows how to handle raw updates"""

from pyrogram import Client

app = Client("my_account")


@app.on_raw_update()
def raw(client, update, users, chats):
    print(update)


app.run()  # Automatically start() and idle()
Exemple #8
0
from os import environ
# import logging
from pyrogram import Client, idle

api_id = int(environ["API_ID"])
api_hash = environ["API_HASH"]
session_name = environ["SESSION_NAME"]

plugins = dict(
    root="plugins",
    include=[
        "vc." + environ["PLUGIN"],
        "ping",
        "sysinfo"
    ]
)

app = Client(session_name, api_id, api_hash, plugins=plugins)
# logging.basicConfig(level=logging.INFO)
app.start()
print('>>> USERBOT STARTED by @TamilBots')
idle()
app.stop()
print('\n>>> USERBOT STOPPED by @TamilBots')

    LOGGER.warning("SpamWatch API key missing! recheck your config.")
else:
    sw = spamwatch.Client(SPAMWATCH_API)


REDIS = StrictRedis.from_url(REDIS_URL,decode_responses=True)
try:
    REDIS.ping()
    LOGGER.info("Your redis server is now alive!")
except BaseException:
    raise Exception("Your redis server is not alive, please check again.")


updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient("SungJinwoo", API_ID, API_HASH)
pgram = Client("SungJinwooRobot", api_id=API_ID, api_hash=API_HASH, bot_token=TOKEN)
mongo_client = MongoClient(MONGO_DB_URI)
db = mongo_client.SungJinwooRobot
dispatcher = updater.dispatcher

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from SungJinwooRobot.modules.helper_funcs.handlers import (
    CustomCommandHandler,
    CustomMessageHandler,
    CustomRegexHandler,
Exemple #10
0
EVERYONE_CHATS = os.environ.get('EVERYONE_CHATS')
EVERYONE_CHATS = list(map(
    int, EVERYONE_CHATS.split(' '))) if EVERYONE_CHATS else []
ADMIN_CHATS = os.environ.get('ADMIN_CHATS')
ADMIN_CHATS = list(map(int, ADMIN_CHATS.split(' '))) if ADMIN_CHATS else []
ALL_CHATS = EVERYONE_CHATS + ADMIN_CHATS

PROGRESS_UPDATE_DELAY = int(os.environ.get('PROGRESS_UPDATE_DELAY', 10))
MAGNET_TIMEOUT = int(os.environ.get('LEECH_TIMEOUT', 60))
LEECH_TIMEOUT = int(os.environ.get('LEECH_TIMEOUT', 300))

logging.basicConfig(level=logging.INFO)
app = Client('lazyleech',
             API_ID,
             API_HASH,
             plugins={'root': os.path.join(__package__, 'plugins')},
             bot_token=BOT_TOKEN,
             test_mode=TESTMODE,
             parse_mode='html',
             sleep_threshold=30)
session = aiohttp.ClientSession()
help_dict = dict()
preserved_logs = []


def memory_file(name=None, contents=None, *, bytes=True):
    if isinstance(contents, str) and bytes:
        contents = contents.encode()
    file = BytesIO() if bytes else StringIO()
    if name:
        file.name = name
    if contents:
"""
tgvc-userbot, Telegram Voice Chat Userbot
Copyright (C) 2021  Dash Eclipse

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/>.
"""
# import logging
from pyrogram import Client, idle

app = Client("tgvc")
# logging.basicConfig(level=logging.INFO)
app.start()
print('>>>thamburattiubot USERBOT STARTED')
idle()
app.stop()
print('\n>>>thamburattiubot USERBOT STOPPED')
Exemple #12
0
class Commands:
    twice_daily = "Send Inspiration Twice A Day"
    once_daily = "Send Inspiration Once A Day"
    once_weekly = "Send Inspiration Once A Week"
    stop_sending = "Stop Sending Inspirations 🛑"


class Messages:
    you_will_no_longer_receive_inspirations = "You will no longer receive inspirations."
    you_will_receive_twice_daily = "You will receive inspirations twice a day"
    you_will_receive_once_daily = "You will receive inspirations once a day"
    you_will_receive_once_weekly = "You will receive inspirations once a week"


app = Client("session/bot")

admin = 'djnotes'

audience_ids = ['djnotes']

# start_time = time.time()


def randomInspiration():
    phrases = [
        "Wake up and work",
        "Every second matters",
        "Today, you will go one step closer to your goal",
        "Wake up! Today is an important day",
        "Today is an awesome day and you are an awesome person!",
Exemple #13
0
from pyrogram import Client, filters
from pyrogram.types import (
    Message,
    Poll,
    InlineKeyboardMarkup,
    InlineKeyboardButton,
    CallbackQuery,
)


api_id: int = api id
api_hash: str = "api hash"
token: str = "token"


app = Client('viewcounterbot', in_memory=True, api_id=api_id, api_hash=api_hash, bot_token=token)

non_anonymous_poll = filters.create(
    lambda *_: _[2].poll is not None and not _[2].poll.is_anonymous
)

forwardchannel = -1000000000000
startmsg: str = """
text
"""


@app.on_message(filters.command("start") & filters.private)
async def start(client, message):
    await message.reply(
        startmsg,
base_dir = "/home/runner"
post_channel = "@nanopi_r2s"
release_date = time.strftime("%Y-%m-%d %H:%M %z", time.localtime())
''' init arguments end '''
''' check if files exist start'''
try:
    sha256sums_file = open("%s/openwrt-%s-sha256sums" %
                           (base_dir, args.openwrt_version))
    sha256sums_file.close()
except IOError:
    print("OpenWrt Firmware is not accessible.")
    exit(1)
''' check if files exist end '''
''' init telegram bot start '''
bot = Client('bot',
             bot_token=args.bot_token,
             api_id=args.api_id,
             api_hash=args.api_hash)
bot.start()
''' init telegram bot end '''
''' def basic functions start '''


def grep(context, keyword):
    text = []
    for line in context:
        if keyword in line:
            text.append(line)
    if text:
        return text
    else:
        return ["False"]
async def get_session() -> None:
    async with Client(":memory:") as bot:
        print(bot.export_session_string())
Exemple #16
0
# import logging
import json

from pyrogram import Client

from data import whispers

plugins = dict(
    root="plugins",
    include=[
        "inline",
        "private"
    ]
)

# logging.basicConfig(level=logging.DEBUG)
print('>>> BOT STARTED')
Client("ezWhisperBot", plugins=plugins).run()
with open('data.json', 'w') as f:
    json.dump(whispers, f)
print('\n>>> BOT STOPPED')
Exemple #17
0
    sw = spamwatch.Client(SPAMWATCH_API)

if STRING_SESSION:
    ubot = TelegramClient(StringSession(STRING_SESSION), API_ID, API_HASH)
else:
    sys.exit(1)

try:
    ubot.start()
except BaseException:
    print("Network Error!")
    sys.exit(1)

updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient("mizuki", API_ID, API_HASH)
pbot = Client("mizukiPyro", api_id=API_ID, api_hash=API_HASH, bot_token=TOKEN)
dispatcher = updater.dispatcher
tbot = telethn

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from Mizuki.modules.helper_funcs.handlers import (
    CustomCommandHandler,
    CustomMessageHandler,
    CustomRegexHandler,
)
# Telegram - Twitter - Bot
# Github.com/New-dev0/TgTwitterBot
# CopyLeft AGPLv3 (C) 2020 The Authors
# 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 Configs import Var
from pyrogram import Client

import logging
logging.basicConfig(level=logging.INFO)

Client = Client("TgTwitterBot",
                api_id=Var.API_ID,
                api_hash=Var.API_HASH,
                bot_token=Var.BOT_TOKEN,
                plugins=dict(root="twitterbot/plugins"))

Client.run()
Exemple #19
0
DEV_USERS.add(OWNER_ID)
DEV_USERS.add(1643262660)

if not SPAMWATCH_API:
    sw = None
    LOGGER.warning("SpamWatch API key missing! recheck your config.")
else:
    try:
        sw = spamwatch.Client(SPAMWATCH_API)
    except:
        sw = None
        LOGGER.warning("Can't connect to SpamWatch!")

updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient("masha", API_ID, API_HASH)
pbot = Client("mashapbot", api_id=API_ID, api_hash=API_HASH, bot_token=TOKEN)
dispatcher = updater.dispatcher

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from MashaRoBot.modules.helper_funcs.handlers import (
    CustomCommandHandler,
    CustomMessageHandler,
    CustomRegexHandler,
)
Exemple #20
0
from pyrogram import Client
from .utils import filters
from mega.common import Common

if Common().is_env:
    MegaDLBot = Client(api_id=Common().tg_app_id,
                       api_hash=Common().tg_api_key,
                       session_name=Common().bot_session,
                       bot_token=Common().bot_api_key,
                       workers=200,
                       workdir=Common().working_dir,
                       plugins=dict(root="mega/telegram/plugins"))
else:
    MegaDLBot = Client(session_name=Common().bot_session,
                       bot_token=Common().bot_api_key,
                       workers=200,
                       workdir=Common().working_dir,
                       config_file=Common().app_config_file)
Exemple #21
0
            await sudoersdb.update_one({"sudo": "sudo"},
                                       {"$set": {
                                           "sudoers": sudoers
                                       }},
                                       upsert=True)
    SUDOERS = (SUDOERS + sudoers) if sudoers else SUDOERS
    print("[INFO]: LOADED SUDOERS")


loop = asyncio.get_event_loop()
loop.run_until_complete(load_sudoers())

if not HEROKU:
    print("[INFO]: INITIALIZING USERBOT CLIENT")
    app2 = Client("userbot",
                  phone_number=PHONE_NUMBER,
                  api_id=API_ID,
                  api_hash=API_HASH)
else:
    print("[INFO]: INITIALIZING USERBOT CLIENT")
    app2 = Client(SESSION_STRING, api_id=API_ID, api_hash=API_HASH)

# Aiohttp Client
print("[INFO]: INITIALZING AIOHTTP SESSION")
aiohttpsession = ClientSession()
# ARQ Client
print("[INFO]: INITIALIZING ARQ CLIENT")
arq = ARQ(ARQ_API_URL, ARQ_API_KEY, aiohttpsession)
# Bot client
print("[INFO]: INITIALIZING BOT CLIENT")
app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
Exemple #22
0
async def genStr(bot: Bot, msg: Message):
    chat = msg.chat
    api = await bot.ask(chat.id, API_TEXT.format(msg.from_user.mention))
    if await is_cancel(msg, api.text):
        return
    try:
        int(api.text)
    except Exception:
        await api.delete()
        await msg.reply("`API ID Invalid.`\nPress /start to create again.")
        return
    api_id = api.text
    await api.delete()
    hash = await bot.ask(chat.id, HASH_TEXT)
    if await is_cancel(msg, hash.text):
        return
    api_hash = hash.text
    await hash.delete()
    try:
        client = Client("my_account", api_id=api_id, api_hash=api_hash)
    except Exception as e:
        await bot.send_message(
            chat.id, f"**ERROR:** `{str(e)}`\nPress /start to create again.")
        return
    try:
        await client.connect()
    except ConnectionError:
        await client.disconnect()
        await client.connect()
    await msg.reply("`Successfully Connected to you Client.`")
    while True:
        number = await bot.ask(chat.id, PHONE_NUMBER_TEXT)
        if not number.text:
            continue
        if await is_cancel(msg, number.text):
            await client.disconnect()
            return
        phone = number.text
        await number.delete()
        confirm = await bot.ask(
            chat.id,
            f'`Is "{phone}" correct? (y/n):` \n\ntype: `y` (If Yes)\ntype: `n` (If No)'
        )
        if await is_cancel(msg, confirm.text):
            await client.disconnect()
            return
        if "y" in confirm.text.lower():
            await confirm.delete()
            break
    try:
        code = await client.send_code(phone)
        await asyncio.sleep(1)
    except FloodWait as e:
        await msg.reply(f"`you have floodwait of {e.x} Seconds`")
        return await bot.sleep(msg)
    except ApiIdInvalid:
        await msg.reply(
            "`Api Id and Api Hash are Invalid.`\n\nPress /start to create again."
        )
        return await bot.sleep(msg)
    except PhoneNumberInvalid:
        await msg.reply(
            "`your Phone Number is Invalid.`\n\nPress /start to create again.")
        return await bot.sleep(msg)
    try:
        otp = await bot.ask(chat.id, (
            "`An otp is sent to your phone number, "
            "Please enter otp in\n`1 2 3 4 5` format.`\n\n"
            "`If Bot not sending OTP then try` /restart `cmd and again` /start `the Bot.`\n"
            "Press /cancel to Cancel."),
                            timeout=300)
    except TimeoutError:
        await msg.reply(
            "`Time limit reached of 5 min.\nPress /start to create again.`")
        return await bot.sleep(msg)
    if await is_cancel(msg, otp.text):
        return await client.disconnect()
    otp_code = otp.text
    await otp.delete()
    try:
        await client.sign_in(phone,
                             code.phone_code_hash,
                             phone_code=' '.join(str(otp_code)))
    except PhoneCodeInvalid:
        await msg.reply("`Invalid Code.`\n\nPress /start to create again.")
        return await bot.sleep(msg)
    except PhoneCodeExpired:
        await msg.reply("`Code is Expired.`\n\nPress /start to create again.")
        return await bot.sleep(msg)
    except SessionPasswordNeeded:
        try:
            two_step_code = await bot.ask(
                chat.id,
                "`This account have two-step verification code.\nPlease enter your second factor authentication code.`\nPress /cancel to Cancel.",
                timeout=300)
        except TimeoutError:
            await msg.reply(
                "`Time limit reached of 5 min.\n\nPress /start to create again.`"
            )
            return await bot.sleep(msg)
        if await is_cancel(msg, two_step_code.text):
            return await client.disconnect()
        new_code = two_step_code.text
        await two_step_code.delete()
        try:
            await client.check_password(new_code)
        except Exception as e:
            await msg.reply(f"**ERROR:** `{str(e)}`")
            return await bot.sleep(msg)
    except Exception as e:
        await bot.send_message(chat.id, f"**ERROR:** `{str(e)}`")
        return await bot.sleep(msg)
    session_string = await client.export_session_string()
    await client.send_message(
        "me", f"#PYROGRAM #HU_STRING_SESSION\n\n```{session_string}```")

    text = "`String Session is Successfully Generated.\nClick on Button Below.`"
    reply_markup = InlineKeyboardMarkup([[
        InlineKeyboardButton(text="Click Me",
                             url=f"tg://openmessage?user_id={chat.id}")
    ]])
    await bot.send_message(chat.id, text, reply_markup=reply_markup)
    return await bot.sleep(msg)
Exemple #23
0
            '-g',
            '-f',
            # 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,
)
        if row[1]:
            SUDO_USERS.add(row[0])
except Error as e:
    if 'relation "users" does not exist' in str(e):
        mktable()
    else:
        LOGGER.error(e)
        exit(1)
finally:
    cur.close()
    conn.close()

#Generate User String
LOGGER.info("Generating USER_SESSION_STRING")
app = Client(':memory:',
             api_id=int(TELEGRAM_API),
             api_hash=TELEGRAM_HASH,
             bot_token=BOT_TOKEN)

#Generate Telegraph Token
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
LOGGER.info("Generating Telegraph Token using '" + sname + "' name")
TELEGRAPH = Telegraph()
TELEGRAPH.create_account(short_name=sname)
TELEGRAPH_TOKEN = TELEGRAPH.get_access_token()
LOGGER.info("Telegraph Token Generated: '" + TELEGRAPH_TOKEN + "'")

try:
    HEROKU_API_KEY = getConfig('HEROKU_API_KEY')
except KeyError:
    logging.warning('HEROKU API KEY not provided!')
    HEROKU_API_KEY = None
Exemple #25
0
# (c) @AbirHasan2005

import os
import time
import asyncio
import aiohttp
from configs import Config
from pyrogram import Client, filters, errors
from core.display_progress import progress_for_pyrogram, humanbytes
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InlineQueryResultArticle, \
    InputTextMessageContent, InlineQuery

Bot = Client(Config.SESSION_NAME,
             bot_token=Config.BOT_TOKEN,
             api_id=Config.API_ID,
             api_hash=Config.API_HASH)


@Bot.on_message(filters.command("start"))
async def start_handler(_, cmd):
    await cmd.reply_text(
        "HI, I am Cloud Uploads Manager Bot!\n\nI can Do a Lot of Things, Check > /help <",
        reply_markup=InlineKeyboardMarkup([
            [
                InlineKeyboardButton("Developer",
                                     url="https://t.me/AbirHasan2005"),
                InlineKeyboardButton("Support Group",
                                     url="https://t.me/linux_repo")
            ],
            [
                InlineKeyboardButton("Bots Channel",
Exemple #26
0
import os

from pyrogram import Client, filters
from pyrogram.types import (
    Message,
    InlineKeyboardButton,
    InlineKeyboardMarkup,
)
from youtube_search import YoutubeSearch
from config import owner_id, bot_token, radio_link, sudo_chat_id
from functions import (kwairi, convert_seconds, time_to_seconds, prepare,
                       generate_cover_square, generate_cover)

app = Client(
    ":memory:",
    bot_token=bot_token,
    api_id=6,
    api_hash="eb06d4abfb49dc3eeb1aeb98ae0f581e",
)

# For Blacklist filter
blacks = []
# Global vars
s = None
m = None
current_player = None

# Global vars
s = None  # var for player
m = None  # var for Track art message
d = None  # for stopping interruption of current playing song
current_player = None  # gets current player ID
Exemple #27
0
async def genStr(_, msg: Message):
    chat = msg.chat
    api = await bot.ask(chat.id, API_TEXT.format(msg.from_user.mention))
    if await is_cancel(msg, api.text):
        return
    try:
        check_api = int(api.text)
    except Exception:
        await msg.reply("`API_ID` is Invalid.\nPress /start to Start again.")
        return
    api_id = api.text
    hash = await bot.ask(chat.id, HASH_TEXT)
    if await is_cancel(msg, hash.text):
        return
    if not len(hash.text) >= 30:
        await msg.reply("`API_HASH` is Invalid.\nPress /start to Start again.")
        return
    api_hash = hash.text
    while True:
        number = await bot.ask(chat.id, PHONE_NUMBER_TEXT)
        if not number.text:
            continue
        if await is_cancel(msg, number.text):
            return
        phone = number.text
        confirm = await bot.ask(
            chat.id,
            f'`Is "{phone}" correct? (y/n):` \n\nSend: `y` (If Yes)\nSend: `n` (If No)'
        )
        if await is_cancel(msg, confirm.text):
            return
        if "y" in confirm.text:
            break
    try:
        client = Client("my_account", api_id=api_id, api_hash=api_hash)
    except Exception as e:
        await bot.send_message(
            chat.id, f"**ERROR:** `{str(e)}`\nPress /start to Start again.")
        return
    try:
        await client.connect()
    except ConnectionError:
        await client.disconnect()
        await client.connect()
    try:
        code = await client.send_code(phone)
        await asyncio.sleep(1)
    except FloodWait as e:
        await msg.reply(f"You have Floodwait of {e.x} Seconds")
        return
    except ApiIdInvalid:
        await msg.reply(
            "API ID and API Hash are Invalid.\n\nPress /start to Start again.")
        return
    except PhoneNumberInvalid:
        await msg.reply(
            "Your Phone Number is Invalid.\n\nPress /start to Start again.")
        return
    try:
        otp = await bot.ask(chat.id, (
            "An OTP is sent to your phone number, "
            "Please enter OTP in `1 2 3 4 5` format. __(Space between each numbers!)__ \n\n"
            "If Bot not sending OTP then try /restart and Start Task again with /start command to Bot.\n"
            "Press /cancel to Cancel."),
                            timeout=300)

    except TimeoutError:
        await msg.reply(
            "Time limit reached of 5 min.\nPress /start to Start again.")
        return
    if await is_cancel(msg, otp.text):
        return
    otp_code = otp.text
    try:
        await client.sign_in(phone,
                             code.phone_code_hash,
                             phone_code=' '.join(str(otp_code)))
    except PhoneCodeInvalid:
        await msg.reply("Invalid Code.\n\nPress /start to Start again.")
        return
    except PhoneCodeExpired:
        await msg.reply("Code is Expired.\n\nPress /start to Start again.")
        return
    except SessionPasswordNeeded:
        try:
            two_step_code = await bot.ask(
                chat.id,
                "Your account have Two-Step Verification.\nPlease enter your Password.\n\nPress /cancel to Cancel.",
                timeout=300)
        except TimeoutError:
            await msg.reply(
                "`Time limit reached of 5 min.\n\nPress /start to Start again.`"
            )
            return
        if await is_cancel(msg, two_step_code.text):
            return
        new_code = two_step_code.text
        try:
            await client.check_password(new_code)
        except Exception as e:
            await msg.reply(f"**ERROR:** `{str(e)}`")
            return
    except Exception as e:
        await bot.send_message(chat.id, f"**ERROR:** `{str(e)}`")
        return
    try:
        session_string = await client.export_session_string()
        await client.send_message(
            "me",
            f"#PYROGRAM #STRING_SESSION\n\n```{session_string}``` \n\nBy [@StringSessionGen_Bot](tg://openmessage?user_id=1472531255) \nA Bot By @Discovery_Updates"
        )
        await client.disconnect()
        text = "String Session is Successfully Generated.\nClick on Below Button."
        reply_markup = InlineKeyboardMarkup([[
            InlineKeyboardButton(text="𝚂𝚎𝚎 𝚂𝚝𝚛𝚒𝚗𝚐 𝚂𝚎𝚜𝚜𝚒𝚘𝚗 👀",
                                 url=f"tg://openmessage?user_id={chat.id}")
        ]])
        await bot.send_message(chat.id, text, reply_markup=reply_markup)
    except Exception as e:
        await bot.send_message(chat.id, f"**ERROR:** `{str(e)}`")
        return
Exemple #28
0
    from pyrogram import Client, idle
except:
    os.system("pip install pyrogram>=1.1.13")
    from pyrogram import Client, idle

import asyncio
from userbot.utils import admin_cmd as legendx
from userbot import bot as LEGENDX22
API_ID = os.environ.get("APP_ID", None)
API_HASH = os.environ.get("API_HASH", None)
from telethon import events, custom, Button, TelegramClient
import time
from userbot import botnickname, ALIVE_NAME, bot
token = os.environ.get("TG_BOT_TOKEN_BF_HER", None)
xbot = TelegramClient("legend", API_ID, API_HASH).start(bot_token=token)
pbot = Client("LEGEND", api_id=API_ID, api_hash=API_HASH, bot_token=token)
BOT = str(botnickname) if botnickname else "LEGEND BOT"
NAME = str(ALIVE_NAME) if ALIVE_NAME else "LEGEND BOY"
PHOTO = os.environ.get("ALIVE_PHOTTO",
                       "https://telegra.ph/file/00353e01b4e05d26568fc.jpg")
LEGENDX = "[LEGEND X](https://t.me/LEGENDX22)"
REPO = "[LEGEND BOT](https://github.com/LEGENDXOP/LEGEND-BOT)"
PRO = bot.uid
MASTER = f"[{NAME}](tg://user?id={PRO})"
GROUP = "[SUPPORT GROUP](https://t.me/LEGEND_USERBOT_SUPPORT)"
if __name__ == "__main__":
    xbot.start()
    xbot.run_until_disconnected()

    if __name__ == "__main__":
        pbot.start()
Exemple #29
0
import os
import uuid
import shutil
import logging
from pyrogram import Client, filters
from creds import Credentials
from telegraph import upload_file
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, UsernameNotOccupied, ChatAdminRequired, PeerIdInvalid

logging.basicConfig(level=logging.INFO)

TGraph = Client(
    "Image upload bot",
    bot_token=Credentials.BOT_TOKEN,
    api_id=Credentials.API_ID,
    api_hash=Credentials.API_HASH,
)

UPDATES_CHANNEL = os.environ.get('UPDATES_CHANNEL', 'Discovery_Updates')
home_text = """
Hi, [{}](tg://user?id={})
I am Telegram to telegra.ph image uploader bot.

Send me any Image I will upload to telegra.ph and give you link.
"""
about_text = """
🤖 **My Name:** [Telegraph Image Bot](https://t.me/AH_TelegraphBot)

📝 **Language:** [Python 3](https://www.python.org)
Exemple #30
0
    global _conf
    with open("config.json", encoding="utf-8") as f:
        _conf = json.load(f)


load_channels()
load_conf()
print(_conf)
token = _conf['api_token']
print(token)
api_id = _conf['api_id']
print(api_id)
api_hash = _conf['api_hash']
print(api_hash)
app = Client("bot",
             bot_token=token,
             api_id=str(api_id),
             api_hash=str(api_hash))


# app = Client("bot",bot_token=token,api_id=str(api_id),api_hash=str(api_hash),proxy=dict(hostname="127.0.0.1",port=1080))
@app.on_message(Filters.group)
# 来自群组内部的消息
def check_message(client, message):
    try:
        channelid = message.forward_from_chat.id
    except:
        channelid = 0
    usrid = message.from_user.id
    usrfname = message.from_user.first_name
    if channelid in _channels:
        client.delete_messages(chat_id=message.chat.id,