Ejemplo n.º 1
0
    async def _new_document(self, _: Client, message: Message):
        devices = []

        if self._config.upnp_enabled:
            devices.extend(await UpnpDeviceFinder.find(self._config))

        if self._config.chromecast_enabled:
            # noinspection PyUnresolvedReferences
            devices.extend(await ChromecastDeviceFinder.find(self._config))

        if self._config.xbmc_enabled:
            devices.extend(await XbmcDeviceFinder.find(self._config))

        if self._config.vlc_enabled:
            devices.extend(await VlcDeviceFinder.find(self._config))

        if devices:
            try:
                filename = pyrogram_filename(message)
            except TypeError:
                filename = "None"

            self._state_machine.set_state(
                message, States.SELECT,
                SelectStateData(message.message_id, str(filename),
                                devices.copy()))

            buttons = [[KeyboardButton(repr(device))] for device in devices]
            buttons.append([KeyboardButton(_CANCEL_BUTTON)])
            markup = ReplyKeyboardMarkup(buttons, one_time_keyboard=True)
            await message.reply("Select a device", reply_markup=markup)

        else:
            await message.reply("Supported devices not found in the network",
                                reply_markup=_REMOVE_KEYBOARD)
Ejemplo n.º 2
0
    async def _new_document(self, _: Client, message: Message):
        devices = []

        for finder in self._finders.get_finders(self._config):
            with async_timeout.timeout(self._config.device_request_timeout + 1):
                devices.extend(await finder.find(self._config))

        if devices:
            try:
                filename = pyrogram_filename(message)
            except TypeError:
                filename = "None"

            self._state_machine.set_state(
                message,
                States.SELECT,
                SelectStateData(
                    message.message_id,
                    str(filename),
                    devices.copy()
                )
            )

            buttons = [[KeyboardButton(repr(device))] for device in devices]
            buttons.append([KeyboardButton(_CANCEL_BUTTON)])
            markup = ReplyKeyboardMarkup(buttons, one_time_keyboard=True)
            await message.reply("Select a device", reply_markup=markup)

        else:
            await message.reply("Supported devices not found in the network", reply_markup=_REMOVE_KEYBOARD)
Ejemplo n.º 3
0
async def get_stickers(client, message):
	if message.from_user.id not in app_user_ids:
		return

	if not DB_AVAILABLE:
		await message.edit("Your database is not avaiable!")
		return

	global TEMP_KEYBOARD, USER_SET
	app = await get_app(message.from_user.id)
	if not app:
		return

	await app.send_message("@Stickers", "/stats")
	await asyncio.sleep(0.2)
	keyboard = await app.get_history("@Stickers", limit=1)
	keyboard = keyboard[0].reply_markup.keyboard

	for x in keyboard:
		for y in x:
			TEMP_KEYBOARD.append(y)

	await app.send_message("@Stickers", "/cancel")
	# cleanup
	await app.delete_messages("@Stickers", [ms.message_id for ms in await app.get_history("@Stickers", limit=4)])
	msg = await message.reply("Please select your kang pack", reply_markup=ReplyKeyboardMarkup(keyboard))
	USER_SET[message.from_user.id] = msg.message_id
	USER_SET["type"] = 1
Ejemplo n.º 4
0
async def settings_sticker(_client, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return
    global TEMP_KEYBOARD, USER_SET
    await app.send_message("@Stickers", "/stats")
    # app.read_history("@Stickers")
    time.sleep(0.2)
    try:
        keyboard = await app.get_history("@Stickers", limit=1)
        keyboard = keyboard[0].reply_markup.keyboard
    except:
        message.message.edit_text(
            "You dont have any sticker pack!\nAdd stickers pack in @Stickers ")
        return
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)
    await app.send_message("@Stickers", "/cancel")
    await message.message.delete()
    msg = await setbot.send_message(
        Owner,
        "Select your stickers for set as kang animation sticker",
        reply_markup=ReplyKeyboardMarkup(keyboard))
    USER_SET[message.from_user.id] = msg.message_id
    USER_SET["type"] = 2
Ejemplo n.º 5
0
async def settings_sticker(_, message):
    if not DB_AVAILABLE:
        await message.edit("You haven't set up a database!")
        return
    global TEMP_KEYBOARD, USER_SET
    await app.send_message('@Stickers', '/stats')
    await asyncio.sleep(0.2)
    try:
        keyboard = await app.get_history('@Stickers', limit=1)
        keyboard = keyboard[0].reply_markup.keyboard
    except IndexError:
        await message.edit(
            'You dont have any sticker pack!\nAdd stickers pack in @Stickers ',
        )
        return
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)
    await app.send_message('@Stickers', '/cancel')
    await message.message.delete()
    msg = await setbot.send_message(
        Owner,
        'Select your stickers for set as kang animation sticker',
        reply_markup=ReplyKeyboardMarkup(keyboard),
    )
    USER_SET[message.from_user.id] = msg.message_id
    USER_SET['type'] = 2
Ejemplo n.º 6
0
def start(client, message):
    app.send_message(chat_id=message.chat.id,
                     text=strings["start"],
                     reply_markup=ReplyKeyboardMarkup([[
                         KeyboardButton(text="/tg40m"),
                         KeyboardButton(text="/eyeofgod")
                     ]]),
                     reply_to_message_id=message["message_id"])
Ejemplo n.º 7
0
def kb(rows = [], **kwargs):
    lines = []
    for row in rows:
        line = []
        for button in row:
            button_type = type(button)
            if button_type == str:
                button = KeyboardButton(button)
            elif button_type == dict:
                button = KeyboardButton(**button)
            
            line.append(button)
        lines.append(line)
    return ReplyKeyboardMarkup(keyboard=lines, **kwargs)
Ejemplo n.º 8
0
async def create_menu(client, message):
    """
        Створюємо ReplyKeyboardMarkup з кнопками 'Інформація про мене' та 'Налаштування'
    """

    await message.reply_text('Виберіть пункт з головного меню.',
                             reply_markup=ReplyKeyboardMarkup(
                                 [
                                     ["Інформація про мене"],  # Перший рядок
                                     ["Налаштування"],  # Другий рядок
                                 ],
                                 resize_keyboard=True  # Використання малої клавіатури
                             )
                             )
async def start(app: Client, message: Message):
    if message.from_user.id in USERS:
        await message.reply_text(plate("hello", USERS[message.from_user.id]))
    else:
        await message.reply_text(
            "Language? Sprache? Linguaggio?",
            reply_markup=ReplyKeyboardMarkup(
                [[
                    KeyboardButton(DE),
                    KeyboardButton(US),
                    KeyboardButton(IT),
                ]],
                resize_keyboard=True,
                one_time_keyboard=True,
            ),
        )
Ejemplo n.º 10
0
def tastiera(app, message):
    if message.chat.id not in chatScommesse:
        message.reply(
            "Gruppo non abilitato, contatta @Anatras02 se credi si tratti di un errore"
        )
        return

    app.send_message(
        message.chat.id,  # Edit this
        "Ecco la tastiera con i giochi!",
        reply_markup=ReplyKeyboardMarkup(
            [["Carte 🃏", "Tiro Con L'Arco 🏹"], ["Testa o Croce 🌕", "Dado 🎲"],
             ["Rune 🔮", "Freccette 🎯"], ["Petardi (Beta) 💣"], ["Random ❓"],
             ["Sorte 🐉", "/gruzzolo 💸"], ["Statistiche 📊", "Chiudi ❌"]],
            resize_keyboard=True  # Make the keyboard smaller
        ))
Ejemplo n.º 11
0
async def get_stickers(client, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return
    global TEMP_KEYBOARD, USER_SET
    await app.send_message("@Stickers", "/stats")
    await asyncio.sleep(0.2)
    keyboard = await app.get_history("@Stickers", limit=1)
    keyboard = keyboard[0].reply_markup.keyboard
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)
    await app.send_message("@Stickers", "/cancel")
    msg = await message.reply("Select your stickers for set as kang sticker",
                              reply_markup=ReplyKeyboardMarkup(keyboard))
    USER_SET[message.from_user.id] = msg.message_id
    USER_SET["type"] = 1
Ejemplo n.º 12
0
def handle_message(bot: Client, msg: Message):
    '''
        This function check if user exists return the user , 
        otherwise it will create a new user.
        In step1 it only figure out what is the message type and make some simpleButton
    '''
    chat_id = msg.chat.id
    bot_text = msg.text
    if msg.text:
        bot.send_message(chat_id, bot_text,
                        reply_markup=ReplyKeyboardMarkup([['salam','khodafez'],['back']],resize_keyboard=True)
                        )
    elif msg.voice:
        print(msg.voice.file_id)
        bot.send_voice(chat_id, msg.voice.file_id)
    elif msg.photo:
        bot.send_message(chat_id, msg.photo.file_id)
    elif msg.document:
        bot.send_message(chat_id, msg.document.file_id)
Ejemplo n.º 13
0
async def get_stickers_animation(_, message):
    if not DB_AVAILABLE:
        await message.edit("You haven't set up a database!")
        return
    global TEMP_KEYBOARD, USER_SET
    await app.send_message('@Stickers', '/stats')
    await asyncio.sleep(0.2)
    keyboard = await app.get_history('@Stickers', limit=1)
    keyboard = keyboard[0].reply_markup.keyboard
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)
    await app.send_message('@Stickers', '/cancel')
    msg = await message.reply(
        'Select your stickers for set as kang animation sticker',
        reply_markup=ReplyKeyboardMarkup(keyboard),
    )
    USER_SET[message.from_user.id] = msg.message_id
    USER_SET['type'] = 2
Ejemplo n.º 14
0
async def create_settings(client, message):
    # Збережемо введення віку в історію активності
    append_history(message.from_user.id, "Create settings")

    if not await is_exist_person(message.from_user.id):
        await message.reply_text('Ви ще не авторизовані 🥺')
        return

    await message.reply_text('Налаштування.',
                             reply_markup=ReplyKeyboardMarkup(
                                 [
                                     ["Змінити вік"],  # Перший рядок
                                     ["Змінити стать"],  # Другий рядок
                                     ["Змінити ім\'я"],  # Третій рядок
                                     ["Назад"],  # Четвертий рядок
                                 ],
                                 resize_keyboard=True  # Використання малої клавіатури
                             )
                             )
    # Видаляємо існуючий handler
    delete_handlers(message.from_user.id)
Ejemplo n.º 15
0
async def settings_sticker(client, message):
    if message.from_user.id not in app_user_ids:
        await message.answer('...no', cache_time=3600, show_alert=True)
        return

    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return

    global TEMP_KEYBOARD, USER_SET
    app = await get_app(message.from_user.id)
    if not app:
        return

    await app.send_message("@Stickers", "/stats")
    await asyncio.sleep(0.2)
    try:
        keyboard = await app.get_history("@Stickers", limit=1)
        keyboard = keyboard[0].reply_markup.keyboard
    except:
        await message.edit(
            "You dont have any sticker pack!\nAdd stickers pack in @Stickers")
        return
    for x in keyboard:
        for y in x:
            TEMP_KEYBOARD.append(y)

    await app.send_message("@Stickers", "/cancel")
    await app.delete_messages(
        "@Stickers",
        [ms.message_id for ms in await app.get_history("@Stickers", limit=4)])
    msg = await slave.send_message(
        message.from_user.id,
        "Select your stickers for set as kang animation sticker",
        reply_markup=ReplyKeyboardMarkup(keyboard))
    USER_SET[message.from_user.id] = msg.message_id
    USER_SET["type"] = 1
Ejemplo n.º 16
0
async def change_name(client, message):
    """
        Змінення імені користувача
    """
    # Збережемо введення віку в історію активності
    append_history(message.from_user.id, "Change name")

    if not await is_exist_person(message.from_user.id):
        await message.reply_text('Ви ще не авторизовані 🥺')
        return

    person = await get_person(message.from_user.id)
    active_users[message.from_user.id] = {"handler": [],
                                          "name": person[0][1],
                                          "age": person[0][2],
                                          "sex": person[0][3]
                                          }
    await message.reply_text('Введіть нове значення, або поверніться назад.',
                             reply_markup=ReplyKeyboardMarkup(
                                 [
                                     ["Назад"],  # Перший рядок
                                 ],
                                 resize_keyboard=True  # Використання малої клавіатури
                             )
                             )
    # Передаємо handler на обробку повідомлень в словник active_users з ключем message.from_user.id
    # При отриманні повідомлення оброблюємо ім'я, потім вік, а потім стать
    active_users[message.from_user.id]["handler"].append(
        app.add_handler(
            MessageHandler(get_name, filters.user(message.from_user.id) & filters.private))
    )
    # Створюємо новий handler на перехід назад
    active_users[message.from_user.id]["handler"].append(
        app.add_handler(
            MessageHandler(create_settings,
                           filters.regex("Назад") & filters.user(message.from_user.id) & filters.private))
    )
Ejemplo n.º 17
0
async def change_sex(client, message):
    """
        Змінення статі користувача
    """
    # Збережемо введення віку в історію активності
    append_history(message.from_user.id, "Change sex")

    if not await is_exist_person(message.from_user.id):
        await message.reply_text('Ви ще не авторизовані 🥺')
        return

    person = await get_person(message.from_user.id)
    active_users[message.from_user.id] = {"handler": [],
                                          "name": person[0][1],
                                          "age": person[0][2],
                                          "sex": person[0][3]
                                          }
    await message.reply_text("Виберіть Вашу стать, або перейдіть назад.",
                             reply_markup=ReplyKeyboardMarkup(
                                 [
                                     ["Чоловік 👨", "Жінка 👩"],  # Перший рядок
                                     ["Назад"],  # Другий рядок
                                 ]
                             )
                             )

    # Створюємо новий handler на отримання статі
    active_users[message.from_user.id]["handler"].append(
        app.add_handler(MessageHandler(get_sex, filters.user(message.from_user.id)))
    )
    # Створюємо новий handler на перехід назад
    active_users[message.from_user.id]["handler"].append(
        app.add_handler(
            MessageHandler(create_settings,
                           filters.regex("Назад") & filters.user(message.from_user.id) & filters.private))
    )
**🔎 چطوری فایل رو سرچ و دانلود کنم؟**
اسم کتاب یا نویسنده یا کلمه های کلیدی مثل __هالیدی__ رو مینویسی و میفرستی.
برای کلمه هایی که توشون عدد وجود داره، عدد رو بدون فاصله کنار کلمه بذار. مثال: __ریاضی۱__
توی نتایج پیدا شده, روی لینک دانلود کلیک میکنی.

**🤷‍♂️ نتونستم فایلی که میخوام رو پیدا کنم.**
اگر نتونستی فایلی که دنبالشی رو پیدا کنی, روی دکمه **{LABEL_REQUEST}** کلیک کن تا بتونیم درخواستت رو پیگیری بکنیم.

**📁 چطوری فایل آپلود کنم؟ **
اگر خواستی فایلی رو آپلود کنی, میتونی با ادمین فایل رو به اشتراک بذاری:
@AG_1380
'''

#KEYBOARDS
KEYBOARD_HELP = ReplyKeyboardMarkup([[LABEL_REQUEST, LABEL_HELP]],
                                    resize_keyboard=True)

KEYBOARD_ADMIN_ADD_FILE = ReplyKeyboardMarkup(
    [[LABEL_NOTE_AND_EXAMPLE, LABEL_BOOK, LABEL_SOLUTION], [LABEL_EXIT]],
    resize_keyboard=True,
    one_time_keyboard=True)

KEYBOARD_EXIT = ReplyKeyboardMarkup(
    [
        [LABEL_EXIT],
    ],
    one_time_keyboard=True,
    resize_keyboard=True,
)

#BUTTONS
Ejemplo n.º 19
0
def updateHandlers(client, message, redis):
    if redis.get("{}Nbot:bigM".format(BOT_ID)):
        return False
    type = message.chat.type
    if message.sender_chat and redis.sismember(
            "{}Nbot:Lchannels".format(BOT_ID), message.chat.id):
        if not message.views:
            Bot("deleteMessage", {
                "chat_id": message.chat.id,
                "message_id": message.message_id
            })
    try:
        userID = message.from_user.id
        chatID = message.chat.id
    except Exception as e:
        return 0
    c = importlib.import_module("lang.arcmd")
    r = importlib.import_module("lang.arreply")

    if (type is "supergroup" or type is "group") and message.outgoing != True:
        chatID = message.chat.id
        userID = message.from_user.id
        rank = isrank(redis, userID, chatID)
        group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatID)
        text = message.text
        title = message.chat.title
        if text and group is False:
            if (rank is "sudo" or rank is "sudos" or rank is "asudo") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add:
                    if redis.get("{}Nbot:autoaddbotN".format(BOT_ID)):
                        auN = int(
                            redis.get("{}Nbot:autoaddbotN".format(BOT_ID)))
                    else:
                        auN = 1
                    if auN >= Bot("getChatMembersCount", {
                            "chat_id": chatID
                    })["result"] and not (rank is "sudo" or rank is "sudos"):
                        Bot(
                            "sendMessage", {
                                "chat_id":
                                chatID,
                                "text":
                                r.Toolow.format((int(
                                    redis.get(
                                        "{}Nbot:autoaddbotN".format(BOT_ID)))
                                                 or 0)),
                                "reply_to_message_id":
                                message.message_id,
                                "parse_mode":
                                "html"
                            })
                        return False
                    GetME = Bot("getChatMember", {
                        "chat_id": chatID,
                        "user_id": BOT_ID
                    })["result"]
                    if (not GetME["can_change_info"]
                            or not GetME["can_delete_messages"]
                            or not GetME["can_invite_users"]
                            or not GetME["can_restrict_members"]
                            or not GetME["can_pin_messages"]):
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.GiveMEall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        return False

                if text == c.add and not redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    locksarray = {
                        'Llink', 'Llongtext', 'Lmarkdown', 'Linline', 'Lfiles',
                        'Lcontact', 'Lbots', 'Lfwd', 'Lnote'
                    }
                    for lock in locksarray:
                        redis.sadd("{}Nbot:{}".format(BOT_ID, lock), chatID)
                    ads = Bot("getChatAdministrators", {"chat_id": chatID})
                    for ad in ads['result']:
                        userId = ad["user"]["id"]
                        userFn = ad["user"]["first_name"]
                        if ad['status'] == "administrator" and int(
                                userId) != int(BOT_ID):
                            setrank(redis, "admin", userId, chatID, "array")
                        if ad['status'] == "creator":
                            setrank(redis, "malk", userId, chatID, "one")
                    add = redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    Bot("exportChatInviteLink", {"chat_id": chatID})
                    kb = InlineKeyboardMarkup(
                        [[InlineKeyboardButton(r.MoreInfo, url="t.me/zx_xx")]])
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
                    sendTO = (redis.get("{}Nbot:sudogp".format(BOT_ID))
                              or SUDO)
                    get = (redis.hget("{}Nbot:links".format(BOT_ID), chatID)
                           or GetLink(chatID) or "https://t.me/zx_xx")
                    kb = InlineKeyboardMarkup(
                        [[InlineKeyboardButton("الرابط 🖇", url=get)]])
                    BY = "<a href=\"tg://user?id={}\">{}</a>".format(
                        userID, message.from_user.first_name)
                    Bot(
                        "sendMessage", {
                            "chat_id": sendTO,
                            "text":
                            f"تم تفعيل مجموعه جديدة ℹ️\nاسم المجموعه : {title}\nايدي المجموعه : {chatID}\nالمنشئ : {BY}\n⎯ ⎯ ⎯ ⎯",
                            "parse_mode": "html",
                            "reply_markup": kb
                        })
                elif text == c.add and redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.srem("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    redis.hdel("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID)

                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd2.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
                if text == c.disabl and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabled.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })

        if text and group is True:
            if (rank is "sudo" or rank is "sudos" or rank is "asudo") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadded.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
                if text == c.disabl and Ckuser(message):
                    redis.srem("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.sadd("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    NextDay_Date = datetime.datetime.today(
                    ) + datetime.timedelta(days=1)
                    redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID, str(NextDay_Date))
                    kb = InlineKeyboardMarkup(
                        [[InlineKeyboardButton(r.MoreInfo, url="t.me/zx_xx")]])
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabl.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
        if group is True:
            t = threading.Thread(target=allGP, args=(client, message, redis))
            t.daemon = True
            t.start()

        if text and group is True:
            if redis.sismember("{}Nbot:publicOrders".format(BOT_ID), chatID):
                x = redis.smembers("{}Nbot:{}:TXPoeders".format(
                    BOT_ID, chatID))
                for x in x:
                    try:
                        x = x.split("=")
                        if re.search(f"^\{x[0]}$", text) or re.search(
                                f"^\{x[0]} (.*)$", text):
                            text = text.replace(x[0], x[1])
                    except Exception as e:
                        print(e)
                message.text = text
            x = redis.smembers("{}Nbot:{}:TXoeders".format(BOT_ID, chatID))
            for x in x:
                try:
                    x = x.split("=")
                    if re.search(f"^\{x[0]}$", text) or re.search(
                            f"^\{x[0]} (.*)$", text):
                        text = text.replace(x[0], x[1])
                except Exception as e:
                    print(e)
            message.text = text

        if (rank is "sudo" or rank is "sudos"
                or rank is "asudo") and group is True:
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.daemon = True
            t.start()

        if text and (rank is "sudo" or rank is "asudo" or rank is "sudos" or
                     rank is "malk" or rank is "acreator" or rank is "creator"
                     or rank is "owner") and group is True:
            t = threading.Thread(target=ranks, args=(client, message, redis))
            t.daemon = True
            t.start()
        if text and (rank is "sudo" or rank is "asudo" or rank is "sudos"
                     or rank is "malk" or rank is "acreator"
                     or rank is "creator" or rank is "owner"
                     or rank is "admin") and group is True and re.search(
                         c.startlock, text):
            if Ckuser(message):
                t = threading.Thread(target=locks,
                                     args=(client, message, redis))
                t.daemon = True
                t.start()
        if (rank is False or rank is 0) and group is True:
            t = threading.Thread(target=delete, args=(client, message, redis))
            t.daemon = True
            t.start()

        if (rank is "sudo" or rank is "asudo" or rank is "sudos"
                or rank is "malk" or rank is "acreator" or rank is "creator"
                or rank is "owner" or rank is "admin") and group is True:
            t = threading.Thread(target=gpcmd, args=(client, message, redis))
            t.daemon = True
            t.start()
        if rank is "vip" and message.forward_date and redis.sismember(
                "{}Nbot:Lfwd".format(BOT_ID), chatID):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })

    if type is "private" and message.outgoing != True:
        text = message.text
        rank = isrank(redis, userID, chatID)
        if (rank is "sudo" or rank is "asudo" or rank is "sudos"):
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.daemon = True
            t.start()
        if text and re.search("^/start$", text):
            userID = message.from_user.id
            userFN = message.from_user.first_name
            redis.sadd("{}Nbot:privates".format(BOT_ID), userID)
            if rank == "sudo":
                kb = ReplyKeyboardMarkup(
                    [[r.RKgp, r.RKgpl], [r.RKaf, r.RKrf], [r.RKf],
                     ["جلب نسخه احتياطيه"], [r.RKub]],
                    resize_keyboard=True)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.sudostart,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": kb
                    })
                return 0
            getbot = client.get_me()
            kb = InlineKeyboardMarkup(
                [[InlineKeyboardButton("TshakeTeam", url="t.me/zx_xx")]])
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.botstart.format(getbot.first_name,
                                              getbot.username),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "reply_markup": kb
                })

        if text and re.search("^/start (.*)$", text):
            tx = text.replace("/start ", "")
            split = tx.split("=")
            order = split[0]
            if order == "showreplylistBOT":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                rank = isrank(redis, userId, chatId)
                if (rank == "sudo" or rank is "asudo" or rank == "sudos"):
                    li = redis.hkeys("{}Nbot:{}".format(BOT_ID, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(
                                r.Delall2R,
                                callback_data=json.dumps(
                                    ["del{}".format(TY + 'BOT'), "", userID])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showreplylist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0 or rank != "vip"
                        or rank != "admin") and group is True:
                    li = redis.hkeys("{}Nbot:{}:{}".format(BOT_ID, chatId, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2R,
                                                 callback_data=json.dumps([
                                                     "del{}".format(TY),
                                                     chatId, userID
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showBlocklist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0
                        or rank != "vip") and group is True:
                    redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx,
                               text)
                    li = redis.smembers("{}Nbot:{}:{}".format(
                        BOT_ID, chatId, TY))
                    if li:
                        i = 1
                        words = ""
                        for ID in li:
                            reply_markup = InlineKeyboardMarkup([[
                                InlineKeyboardButton(r.Blocklistone,
                                                     callback_data=json.dumps([
                                                         "delfromb", TY,
                                                         userID, chatId
                                                     ])),
                            ]])
                            if TY == "blockanimations":
                                Bot(
                                    "sendAnimation", {
                                        "chat_id": userId,
                                        "animation": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockSTICKERs":
                                Bot(
                                    "sendSticker", {
                                        "chat_id": userId,
                                        "sticker": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockphotos":
                                Bot(
                                    "sendPhoto", {
                                        "chat_id": userId,
                                        "photo": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockTEXTs":
                                words = words + "\n" + str(
                                    i) + " - {" + ID + "}"
                                i += 1
                                if len(words) > 3000:
                                    Bot(
                                        "sendMessage", {
                                            "chat_id": userId,
                                            "text": words,
                                            "reply_to_message_id":
                                            message.message_id,
                                            "parse_mode": "html"
                                        })
                                    words = ''
                        if TY == "blockTEXTs":

                            Bot(
                                "sendMessage", {
                                    "chat_id": userId,
                                    "text": words,
                                    "reply_to_message_id": message.message_id,
                                    "parse_mode": "html"
                                })

                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2,
                                                 callback_data=json.dumps([
                                                     "delBL", TY, userID,
                                                     chatId
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.Delall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html",
                                "reply_markup": reply_markup
                            })
                    else:
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.listempty2,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
Ejemplo n.º 20
0
buttons = [
    [
        KeyboardButton(text='/ontem'),
        KeyboardButton(text='/hoje'),
        KeyboardButton(text='/amanha'),
    ],
    [
        KeyboardButton(text='/dominical'),
        KeyboardButton(text='/santododia'),
        KeyboardButton(text='/calendario'),
    ],
    [
        KeyboardButton(text='/help'),
    ],
]
keyboard = ReplyKeyboardMarkup(keyboard=buttons, resize_keyboard=True)

help_text = 'Welcomes everyone that enters a group chat that this bot is a ' \
            'part of. By default, only the person who invited the bot into ' \
            'the group is able to change settings.\nCommands:\n\n' \
            '/welcome - Set welcome message\n' \
            '/goodbye - Set goodbye message\n' \
            '/disable_welcome - Disable the goodbye message\n' \
            '/disable_goodbye - Disable the goodbye message\n' \
            '/lock - Only the person who invited the bot can change messages\n' \
            '/unlock - Everyone can change messages\n' \
            '/quiet - Disable "Sorry, only the person who..." ' \
            '& help messages\n' \
            '/unquiet - Enable "Sorry, only the person who..." ' \
            '& help messages\n\n' \
            '/msg <msg> - To send message\n' \
Ejemplo n.º 21
0
def buton_ver(liste: list, adet: int) -> ReplyKeyboardMarkup:
    return ReplyKeyboardMarkup(dilimleyici(liste, adet), resize_keyboard=True)
Ejemplo n.º 22
0
from pyrogram import Client
from pyrogram.types import Message, ReplyKeyboardMarkup, KeyboardButton ,ReplyKeyboardRemove

#id , hash , token will read from config.ini
app = Client("my_bot")

data =[]
MAIN_KEYBOARD = ReplyKeyboardMarkup([['set name','set age'],['my profile']],resize_keyboard=True)

class MyUser:
    def __init__(self, user_id):
        self.id = user_id
        self.state = 0
        self.name = None
        self.age = None

def check_user(user_id): 
    '''
        This function check if user exists return the user , 
        otherwise it will create a new user.
        In step2 it will help the user make a profile using those buttons
    '''
    for user in data:
        if user_id == user.id:
            return user
    new_user = MyUser(user_id)
    data.append(new_user)
    return new_user
    
@app.on_message()
def handle_message(bot: Client , msg: Message):
Ejemplo n.º 23
0
def main_markup():
    reply_markup = ReplyKeyboardMarkup(
        [
            ["🔥 Новинки", "🔈 Слушают сейчас"],
        ], resize_keyboard=True)
    return reply_markup