Ejemplo n.º 1
0
    if me:
        toggle = "Stop Bot"
    else:
        toggle = "Start Bot"
    list_button = [[InlineKeyboardButton(toggle, callback_data="toggle_startbot"),
                    InlineKeyboardButton("Restart Bot", callback_data="restart_bot")],
                   [InlineKeyboardButton("Set Sticker", callback_data="setsticker")],
                   [InlineKeyboardButton("Set Theme", callback_data="theme")]]
    if HEROKU_API:
        list_button.append([InlineKeyboardButton("Heroku Config Vars", callback_data="heroku_vars")])
        list_button.append([InlineKeyboardButton("Restart Heroku app", callback_data="restart_heroku")])
        list_button.append([InlineKeyboardButton("Change Repo Source", callback_data="change_repo")])
    return InlineKeyboardMarkup(list_button)


@setbot.on_callback_query(filters.regex("^toggle_startbot"))
async def start_stop_bot(client, query):
    try:
        await naruto.stop()
    except ConnectionError:
        await reload_userbot()
        text = await get_text_settings()
        button = await get_button_settings()
        text += "\n✅ Bot was started!"
        try:
            await query.message.edit_text(text, reply_markup=button)
        except errors.exceptions.bad_request_400.MessageNotModified:
            pass
        await client.answer_callback_query(query.id, "Bot was started!")
        return
    text = await get_text_settings()
Ejemplo n.º 2
0
# 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 pyrogram import Client, filters
from twitterbot import api, AUTH
from twitterbot.funcs import user_eazy


@Client.on_inline_query(filters.regex("^followers$") & filters.user(AUTH))
async def getfollowers(client, query):
    flowers = api.followers()
    results = user_eazy(flowers)
    num = len(results)
    tet = f"Showing {num} Results !"
    if num == 0:
        tet = "Sad, You Dont have Any Follower."
    await query.answer(results,
                       switch_pm_text=tet,
                       switch_pm_parameter="start")
Ejemplo n.º 3
0
        except Exception:
            return
        keyboard = InlineKeyboardMarkup([[
            InlineKeyboardButton(
                text="🚨   Unmute   🚨",
                callback_data=f"unmute_{user_id}",
            )
        ]])
        return await message.reply_text(
            f"Imagine flooding the chat in front of me, Muted {mention} for an hour!",
            reply_markup=keyboard,
        )
    DB[chat_id][user_id] += 1


@app.on_callback_query(filters.regex("unmute_"))
async def flood_callback_func(_, cq: CallbackQuery):
    from_user = cq.from_user
    permissions = await member_permissions(cq.message.chat.id, from_user.id)
    permission = "can_restrict_members"
    if permission not in permissions:
        return await cq.answer(
            "You don't have enough permissions to perform this action.\n" +
            f"Permission needed: {permission}",
            show_alert=True,
        )
    user_id = cq.data.split("_")[1]
    await cq.message.chat.unban_member(user_id)
    text = cq.message.text.markdown
    text = f"~~{text}~~\n\n"
    text += f"__User unmuted by {from_user.mention}__"
Ejemplo n.º 4
0
from pyrogram import Client, filters
from pyromod.helpers import ikb
from pyromod.nav import Pagination
from userlixo.config import cmds


@Client.on_callback_query(filters.sudoers
                          & filters.regex('^list_commands (?P<page>\d+)'))
async def on_list_commands_cq(c, cq):
    await on_list_commands_u(c, cq)


async def on_list_commands_u(c, u):
    lang = u._lang
    is_query = hasattr(u, 'data')
    page = int(u.matches[0]['page'])

    item_format = 'info_command {} {}'
    page_format = 'list_commands {}'

    layout = Pagination([*cmds.items()],
                        item_data=lambda i, pg: item_format.format(i[0], pg),
                        item_title=lambda i, pg: i[0],
                        page_data=lambda pg: page_format.format(pg))

    lines = layout.create(page, columns=2, lines=3)
    if is_query:
        lines.append([(lang.back, 'start')])

    keyb = ikb(lines)
    await (u.edit if is_query else u.reply)(lang.commands_text, keyb)
Ejemplo n.º 5
0
from script import script
from database.database import *

from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton

from hachoir.metadata import extractMetadata
from hachoir.parser import createParser
from datetime import datetime
from PIL import Image

from plugins.helpers import (progress_for_pyrogram, humanbytes, headers,
                             take_screen_shot, DownLoadFile)


@Client.on_message(filters.private & filters.regex(pattern=".*http.*"))
async def zee5_capture(bot, update):

    if update.from_user.id in Config.BANNED_USERS:
        await bot.delete_messages(chat_id=update.chat.id,
                                  message_ids=update.message_id,
                                  revoke=True)
        return

    logger.info(update.from_user.id)

    if "zee5" in update.text:
        try:
            w = update.text
            req1 = requests.get("https://useraction.zee5.com/tokennd").json()
            rgx = re.findall("([0-9]?\w+)", w)[-3:]
Ejemplo n.º 6
0
class NotesPlugin(plugin.Plugin, NotesBase):
    name: ClassVar[str] = "Notes"
    helpable: ClassVar[bool] = True
    notes_db: AsyncIOMotorCollection
    lock: asyncio.Lock
    cache: Dict[str, Any]

    @listener.on("get")
    async def get_notes_cmd(self, message):
        """Notes command trigger."""
        args = message.command
        if len(args) >= 2 and args[1].lower() == "noformat":
            await self.get_note(message, args[0], noformat=True)
        elif len(args) >= 1:
            await self.get_note(message, args[0])

    @listener.on(filters=filters.regex(r"^#[^\s]+"), update="message")
    async def get_notes_hash(self, message):
        """Notes hashtag trigger."""
        msg = message.text
        if not msg:
            return

        args = msg.split()
        if len(args) >= 2 and args[1].lower() == "noformat":
            await self.get_note(message, args[0][1:], noformat=True)
        elif len(args) >= 1:
            await self.get_note(message, args[0][1:])

    @listener.on("save", admin_only=True)
    async def cmd_note(self, message: Message) -> str:
        """Save notes."""
        chat_id = message.chat.id
        if len(message.command) < 2 and not message.reply_to_message:
            return await message.reply_text(await self.bot.text(
                chat_id, "notes-invalid-args"))

        name = message.command[0]
        text, msg_type, content, buttons = self.get_msg_type(message)
        await self.add_note(
            message.chat.title,
            chat_id,
            name,
            text,
            msg_type,
            content,
            buttons,
        )
        await message.reply_text(await self.bot.text(chat_id, "note-saved",
                                                     name))

    @listener.on("notes")
    async def cmd_notelist(self, message) -> str:
        """View chat notes."""
        chat_id = message.chat.id
        check = await self.notes_db.find_one({"chat_id": chat_id})

        if not check or not check.get("notes"):
            return await message.reply_text(await
                                            self.bot.text(chat_id, "no-notes"))

        notes = await self.bot.text(chat_id, "note-list", message.chat.title)
        for key in check.get("notes").keys():
            notes += f"× `{key}`\n"
        return await message.reply_text(notes)

    @listener.on(["clear", "delnote"], admin_only=True)
    async def cmd_delnote(self, message):
        """Delete chat note."""
        chat_id = message.chat.id
        if not message.command:
            return await message.reply_text(await self.bot.text(
                chat_id, "notes-del-noargs"))
        name = message.command[0]

        check = await self.notes_db.find_one({"chat_id": chat_id})
        if check is None:
            return await message.reply_text(await
                                            self.bot.text(chat_id, "no-notes"))
        if check is not None and not check.get("notes").get(name):
            return await message.reply_text(await self.bot.text(
                chat_id, "notes-not-exist"))

        await self.del_note(chat_id, name)
        return await message.reply_text(await
                                        self.bot.text(chat_id, "notes-deleted",
                                                      name))
Ejemplo n.º 7
0
""",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton("Назад", callback_data="help"),
                InlineKeyboardButton("На главную", callback_data="start")
            ]]),
            disable_web_page_preview=True,
            parse_mode="html")


# https://docs.pyrogram.org/start/examples/bot_keyboards
# Reply with inline keyboard
@Jebot.on_message(filters.private
                  & filters.text
                  & ~filters.edited
                  & filters.regex(YTDL_REGEX))
async def ytdl_with_button(_, message: Message):
    await message.reply_text(
        "**Выбери что хочешь скачать 🤗**",
        reply_markup=InlineKeyboardMarkup([[
            InlineKeyboardButton("Аудио 🎵", callback_data="ytdl_audio"),
            InlineKeyboardButton("Видео 🎬", callback_data="ytdl_video")
        ]]),
        quote=True)


@Jebot.on_callback_query(filters.regex("^ytdl_audio$"))
async def callback_query_ytdl_audio(_, callback_query):
    try:
        url = callback_query.message.reply_to_message.text
        ydl_opts = {
Ejemplo n.º 8
0
from pyrogram import Client, filters
from pyromod.helpers import ikb
import inspect

@Client.on_callback_query(filters.sudoers & filters.regex('^settings'))
async def on_settings_cq(c, cq):
    await on_settings_u(c, cq)

@Client.on_message(filters.sudoers & filters.regex('^/settings'))
async def on_settings_txt(c, m):
    await on_settings_u(c,m)

async def on_settings_u(c, u):
    lang = u._lang
    is_query = hasattr(u, 'data')
    
    lines = [
        [(lang.language, 'setting_language')],
        [(lang.sudoers, 'setting_sudoers')],
        [(lang.env_vars, 'setting_env')]
    ]
    if is_query:
        lines.append([ (lang.back, 'start') ])
    keyb = ikb(lines)
    
    await (u.edit if is_query else u.reply)(lang.settings_text, keyb)
Ejemplo n.º 9
0
from pyrogram.types import Message
from pyrogram.methods.messages.download_media import DEFAULT_DOWNLOAD_DIR
from pyrogram.errors.exceptions.bad_request_400 import ChatAdminRequired
from pyrogram.errors.exceptions.flood_420 import FloodWait
from pytgcalls import GroupCall
import ffmpeg

VOICE_CHATS = {}
main_filter = (filters.group
               & filters.text
               & filters.outgoing
               & ~filters.edited
               & ~filters.via_bot)


@Client.on_message(main_filter & filters.regex("^!join_vc$"))
async def join_voice_chat(client, message: Message):
    input_filename = os.path.join(client.workdir, DEFAULT_DOWNLOAD_DIR,
                                  "input.raw")
    if message.chat.id in VOICE_CHATS:
        response = " Already Joined the Voice Chat"
        await update_userbot_message(message, message.text, response)
        return
    chat_id = message.chat.id
    group_call = GroupCall(client, input_filename)
    await group_call.start(chat_id, False)
    VOICE_CHATS[chat_id] = group_call
    response = " Joined the Voice Chat"
    await update_userbot_message(message, message.text, response)

Ejemplo n.º 10
0
import os
import socket
import asyncio
from pyrogram import Client, filters, emoji
from pyrogram.types import Message

DELETE_DELAY = 8


@Client.on_message(
    filters.chat("VCSets")
    & filters.text
    & ~filters.edited
    & filters.regex('^/paste$'))
async def upload_paste_to_ezup_pastebin(_, m: Message):
    reply = m.reply_to_message
    if not reply:
        return
    paste_content = await _get_paste_content(reply)
    if not paste_content:
        response = await m.reply_text(f"{emoji.ROBOT} ezpaste: invalid")
        await _delay_delete_messages([response, m])
        return
    url = await _netcat('ezup.dev', 9999, paste_content)
    await reply.reply_text(f"{emoji.ROBOT} ezpaste: {url}")
    await m.delete()


async def _get_paste_content(m: Message):
    if m.text:
        return m.text
Ejemplo n.º 11
0
__MODULE__ = "Karma"
__HELP__ = """[UPVOTE] - Use upvote keywords like "+", "+1", "thanks" etc to upvote a message.
[DOWNVOTE] - Use downvote keywords like "-", "-1", etc to downvote a message.
Reply to a message with /karma to check a user's karma
Send /karma without replying to any message to chek karma list of top 10 users"""


regex_upvote = r"^((?i)\+|\+\+|\+1|thx|tnx|ty|thank you|thanx|thanks|pro|cool|good|👍)$"
regex_downvote = r"^(\-|\-\-|\-1|👎)$"


@app.on_message(filters.text
                & filters.group
                & filters.incoming
                & filters.reply
                & filters.regex(regex_upvote)
                & ~filters.via_bot
                & ~filters.bot
                & ~filters.edited,
                group=karma_positive_group)
@capture_err
async def upvote(_, message):
    if message.reply_to_message.from_user.id == message.from_user.id:
        return
    chat_id = message.chat.id
    user_id = message.reply_to_message.from_user.id
    user_mention = message.reply_to_message.from_user.mention
    current_karma = await get_karma(chat_id, await int_to_alpha(user_id))
    if current_karma:
        current_karma = current_karma['karma']
        karma = current_karma + 1
Ejemplo n.º 12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Dark Angel

import os
import sys
import asyncio
from pyrogram import Client, filters
from pyrogram.types import CallbackQuery

@Client.on_callback_query(filters.regex(r'^stop_btn$'))
async def stop_button(c: Client, cb: CallbackQuery):
    await cb.message.delete()
    await cb.answer()
    msg = await c.send_message(
        text="<i>Trying To Stoping.....</i>",
        chat_id=cb.message.chat.id
    )
    await asyncio.sleep(5)
    await msg.edit("<i>File Forword Stoped Successfully �</i>")
    os.execl(sys.executable, sys.executable, *sys.argv)
    
@Client.on_callback_query(filters.regex(r'^close_btn$'))
async def close(bot, update):
    await update.answer()
    await update.message.delete()
Ejemplo n.º 13
0
        await m.reply_text(tlang(m, "admin.not_admin"))
    except UserNotParticipant:
        await m.reply_text(
            "How can I unmute a user who is not a part of this chat?")
    except RightForbidden:
        await m.reply_text(tlang(m, "admin.unmute.bot_no_right"))
    except RPCError as ef:
        await m.reply_text((tlang(m, "general.some_error")).format(
            SUPPORT_GROUP=SUPPORT_GROUP,
            ef=ef,
        ), )
        LOGGER.error(ef)
    return


@Alita.on_callback_query(regex("^unmute_"))
async def unmutebutton(c: Alita, q: CallbackQuery):
    splitter = (str(q.data).replace("unmute_", "")).split("=")
    user_id = int(splitter[1])
    user = await q.message.chat.get_member(q.from_user.id)

    if not user.can_restrict_members and user.id != OWNER_ID:
        await q.answer(
            "You don't have enough permission to do this!\nStay in your limits!",
            show_alert=True,
        )
        return
    whoo = await c.get_users(user_id)
    try:
        await q.message.chat.unban_member(user_id)
    except RPCError as e:
Ejemplo n.º 14
0
@Alita.on_message(filters.command("banall", DEV_PREFIX_HANDLER) & dev_filter)
async def get_stats(_: Alita, m: Message):
    await m.reply_text(
        "Are you sure you want to ban all members in this group?",
        reply_markup=InlineKeyboardMarkup([
            [
                InlineKeyboardButton("⚠️ Confirm",
                                     callback_data="ban.all.members"),
                InlineKeyboardButton("❌ Cancel", callback_data="close"),
            ],
        ], ),
    )
    return


@Alita.on_callback_query(filters.regex("^ban.all.members$"))
async def banallnotes_callback(c: Alita, q: CallbackQuery):
    await q.message.reply_text("<i><b>Banning All Members...</b></i>")
    users = []
    fs = 0
    async for x in c.iter_chat_members(chat_id=q.message.chat.id):
        try:
            if fs >= 5:
                await sleep(5)
            await c.kick_chat_member(chat_id=q.message.chat.id,
                                     user_id=x.user.id)
            users.append(x.user.id)
        except BaseException:
            fs += 1

    rply = f"Users Banned:\n{users}"
Ejemplo n.º 15
0
             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(
        f"**Hi {message.chat.first_name}!**\n\n"
        "I'm GPlink Generator Bot. Just Send Me Link And Get Short Link n\n Support HB4All @HB4All_bot"
    )


@bot.on_message(filters.regex(r'https?://[^\s]+') & filters.private)
async def link_handler(bot, message):
    link = message.matches[0].group(0)
    try:
        short_link = await get_shortlink(link)
        await message.reply(f'Here Is Your [Short Link]({short_link})',
                            quote=True)
    except Exception as e:
        await message.reply(f'Error: {e}', quote=True)


async def get_shortlink(link):
    url = 'https://gplinks.in/api'
    params = {'api': API_KEY, 'url': link}

    async with aiohttp.ClientSession() as session:
Ejemplo n.º 16
0
        pro = "My name is Mizu."
        try:
            await daisyx.send_chat_action(message.chat.id, "typing")
            await message.reply_text(pro)
        except CFError as e:
            print(e)
    else:
        try:
            await daisyx.send_chat_action(message.chat.id, "typing")
            await message.reply_text(result)
        except CFError as e:
            print(e)


@daisyx.on_message(
    filters.regex("Mizu|mizu|MizuX|mizux") & ~filters.bot & ~filters.via_bot
    & ~filters.forwarded & ~filters.reply & ~filters.private)
async def inuka(client, message):
    test = str(message.text)
    test = emoji.demojize(test.strip())
    if "mizu" in test or 'Mizu' in test:
        try:
            test = test.replace('mizu', 'Jessica')
        except:
            test = test.replace('Mizu', 'Jessica')
        r = (
            '\n    \"consent\": true,\n    \"ip\": \"::1\",\n    \"question\": \"{}\"\n'
        ).format(test)
        k = f"({r})"
        new_string = k.replace("(", "{")
        lol = new_string.replace(")", "}")
Ejemplo n.º 17
0
        item=content_id,
        type=content_type,
    )
    if notify is None:
        status = "🔔"
    else:
        status = "🔕"
    return (
        f"{status} {lang.notify}",
        f"notify {content_type} {content_id} {recipient_type} {recipient.id}",
    )


@Amime.on_callback_query(
    filters.regex(
        r"^notify (?P<c_type>\w+) (?P<c_id>\d+) (?P<r_type>\w+) (?P<r_id>(?:\-)?\d+)"
    ))
async def notify_callback(bot: Amime, callback: CallbackQuery):
    content_type = callback.matches[0]["c_type"]
    content_id = int(callback.matches[0]["c_id"])
    recipient_type = callback.matches[0]["r_type"]
    recipient_id = int(callback.matches[0]["r_id"])
    message = callback.message
    chat = message.chat
    user = callback.from_user
    lang = callback._lang

    if recipient_type == "group":
        if not await filters.administrator(bot, callback):
            return
    elif content_type == "episodes":
Ejemplo n.º 18
0
    result = result.replace("I was created by Lyciabot Team.",
                            "I was created by @madepranav Team.")
    result = result.replace("<a href=\\", "<a href =")
    result = result.replace("<\/a>", "</a>")
    red = result
    if not "en" in lan and not lan == "":
        red = translator.translate(red, lang_tgt=lan[0])
    try:
        await LYCIA.send_chat_action(message.chat.id, "typing")
        await message.reply_text(red)
    except CFError as e:
        print(e)


@LYCIA.on_message(
    filters.regex("Lycia|lycia|LYCIA")
    & ~filters.bot
    & ~filters.via_bot
    & ~filters.forwarded
    & ~filters.reply
    & ~filters.channel)
async def redaura(client, message):
    msg = message.text
    if msg.startswith("/") or msg.startswith("@"):
        message.continue_propagation()
    u = msg.split()
    emj = extract_emojis(msg)
    msg = msg.replace(emj, "")
    if ([(k) for k in u if k.startswith("@")]
            and [(k) for k in u if k.startswith("#")]
            and [(k) for k in u if k.startswith("/")]
Ejemplo n.º 19
0
        key = Config.CMD_TRIGGER + cmd
        key_ = Config.SUDO_TRIGGER + cmd
        if cmd in commands:
            out_str = f"<code>{cmd}</code>\n\n{commands[cmd].about}"
        if key in commands:
            out_str = f"<code>{key}</code>\n\n{commands[key].about}"
        elif key_ in commands:
            out_str = f"<code>{key_}</code>\n\n{commands[key_].about}"
        else:
            out_str = f"<i>No Command Found for</i>: <code>{cmd}</code>"
        await msg.reply(out_str,
                        parse_mode='html',
                        disable_web_page_preview=True)

    @userge.bot.on_callback_query(
        filters=filters.regex(pattern=r"\((.+)\)(next|prev)\((\d+)\)"))
    @check_owner
    async def callback_next_prev(callback_query: CallbackQuery):
        cur_pos = str(callback_query.matches[0].group(1))
        n_or_p = str(callback_query.matches[0].group(2))
        p_num = int(callback_query.matches[0].group(3))
        p_num = p_num + 1 if n_or_p == "next" else p_num - 1
        pos_list = cur_pos.split('|')
        if len(pos_list) == 1:
            buttons = parse_buttons(p_num, cur_pos,
                                    lambda x: f"{_CATEGORY.get(x, '📁')} {x}",
                                    userge.manager.get_all_plugins())
        elif len(pos_list) == 2:
            buttons = parse_buttons(
                p_num, cur_pos, lambda x: f"🗃 {x}",
                userge.manager.get_all_plugins()[pos_list[-1]])
Ejemplo n.º 20
0
    y = await userge.send_inline_bot_result(chat_id=message.chat.id,
                                            query_id=x.query_id,
                                            result_id=x.results[0].id)
    for i in y.updates:
        if isinstance(i, (UpdateNewMessage, UpdateNewChannelMessage)):
            datax = (((i["message"].reply_markup.rows[0].buttons[0].data
                       ).decode("utf-8")).split("|"))[2]
            break
    await message.delete()
    STORE_DATA[datax] = {"chat_id": message.chat.id, "msg_id": y.updates[0].id}


if userge.has_bot:

    @userge.bot.on_callback_query(
        filters.regex(pattern=r"^ytdl(\S+)\|(\d+)\|(\d+)$"))
    async def ytdl_callback(_, c_q: CallbackQuery):
        startTime = time()
        inline_mode = True
        u_id = c_q.from_user.id
        if u_id not in Config.OWNER_ID and u_id not in Config.SUDO_USERS:
            return await c_q.answer("𝘿𝙚𝙥𝙡𝙤𝙮 𝙮𝙤𝙪𝙧 𝙤𝙬𝙣 𝙐𝙎𝙀𝙍𝙂𝙀-𝙓",
                                    show_alert=True)
        choice_id = c_q.matches[0].group(2)
        i_q_id = c_q.matches[0].group(3)
        callback_continue = "Downloading Video Please Wait..."
        callback_continue += f"\n\nFormat Code : {choice_id}"
        await c_q.answer(callback_continue, show_alert=True)
        upload_msg = await userge.send_message(Config.LOG_CHANNEL_ID,
                                               "Uploading...")
        yt_code = c_q.matches[0].group(1)
Ejemplo n.º 21
0
    playing = None
    if message.chat.id in callsmusic.pytgcalls.active_calls:
        playing = True
    queue = que.get(message.chat.id)
    stats = updated_stats(message.chat, queue)
    if stats:
        if playing:
            await message.reply(stats, reply_markup=r_ply('pause'))

        else:
            await message.reply(stats, reply_markup=r_ply('play'))
    else:
        await message.reply('Silahkan hidupkan dulu vcg nya!')


@Client.on_callback_query(filters.regex(pattern=r'^(playlist)$'))
async def p_cb(b, cb):
    global que
    qeue = que.get(cb.message.chat.id)
    type_ = cb.matches[0].group(1)
    chat_id = cb.message.chat.id
    m_chat = cb.message.chat
    the_data = cb.message.reply_markup.inline_keyboard[1][0].callback_data
    if type_ == 'playlist':
        queue = que.get(cb.message.chat.id)
        if not queue:
            await cb.message.edit('Player is idle')
        temp = []
        for t in queue:
            temp.append(t)
        now_playing = temp[0][0]
Ejemplo n.º 22
0
        kwargs["yt_id"],
        "by_user": (await userge.get_user_dict(
            m.from_user, attr_dict=True)).mention if m.from_user else None,
    })

    if (pl_length := len(gc.playlist)) == 1:
        await play_now(gc)
        await m.delete()
    elif not media_grp:
        text = f"Added to Queue at **#{pl_length - 1}\nSONG :** `{title}`"
        await m.edit((f"[\u200c]({thumb})" + text) if thumb else text)


if userge.has_bot:

    @userge.bot.on_callback_query(filters.regex(pattern=r"^vcbtn_([a-z]+)$"))
    @check_owner
    async def manage_vc_settings(c_q: CallbackQuery):
        setting = c_q.matches[0].group(1)
        chat_id = c_q.message.chat.id
        gc = await get_groupcall(chat_id)
        if setting == "back":
            await c_q.answer()
            text, buttons = voice_chat_helpers_buttons()
        else:
            if setting == "delete":
                return await c_q.message.delete()
            if setting == "debug":
                await c_q.answer("Debugging ...")
                await gc.leave()
                gc = await get_groupcall(chat_id)
Ejemplo n.º 23
0
──「 **Vulgar Filter** 」──
-> `vulgar`
Turns on & off vulgar filter

Current words: 'n***a', 'nigger', 'coon', 'f**k', 'bitch'

"""

vulgar_filter = False

bad_words = ['n***a', 'nigger', 'coon', 'bitch']
f_word = ['f**k', 'suck']


@app.on_message(~filters.regex(r"^\.\w*") & filters.me)
async def vulgar_f(_client, message):
    if not vulgar_filter:
        return
    try:
        txt = None
        if message.caption:
            txt = message.caption
        elif message.text:
            txt = message.text

        for word in bad_words:
            txt = re.sub(word, 'bruh', txt, flags=re.IGNORECASE)

        for word in f_word:
            txt = re.sub(word, 'duck', txt, flags=re.IGNORECASE)
Ejemplo n.º 24
0
    @ubot.on_message(allowForwardFilter & ~filters.user(Config.OWNER_ID) & filters.private & filters.incoming & ~filters.command("start"))
    async def forward_bot(_, message: Message):
        found = await BOT_BAN.find_one({'user_id': message.from_user.id})
        if found:
            return
        else:
            msg_id = message.message_id
            try:
                msg_owner = await ubot.forward_messages(Config.OWNER_ID, message.chat.id, msg_id)
            except MessageIdInvalid:
                return
            update = bool(os.path.exists(PATH))
            await dumper(msg_owner.message_id, message.from_user.id, update)

    
    @ubot.on_message(allowForwardFilter & filters.user(Config.OWNER_ID) & filters.private & filters.reply & ~filters.regex(pattern=r"^\/.+")) 
    async def forward_reply(_, message: Message):
        replied = message.reply_to_message
        to_user = replied.forward_from
        msg_id = message.message_id
        if not to_user:
            if replied.forward_sender_name:
                try:
                    data = json.load(open(PATH))
                    user_id = data[0][str(replied.message_id)]
                    await ubot.forward_messages(user_id, message.chat.id, msg_id)
                except BadRequest:
                    return
                except:
                    await ubot.send_message(message.chat.id, "`You can't reply to old messages with if user's forward privacy is enabled`", del_in=10)
                    return
Ejemplo n.º 25
0
    result = result.replace('"}', "")
    result = result.replace("Aco", "Daisy")
    result = result.replace("<a href=\\", "<a href =")
    result = result.replace("<\/a>", "</a>")
    pro = result
    if not "en" in lan and not lan == "":
        pro = translator.translate(pro, lang_tgt=lan[0])
    try:
        await daisyx.send_chat_action(message.chat.id, "typing")
        await message.reply_text(pro)
    except CFError as e:
        print(e)


@daisyx.on_message(
    filters.regex("Daisy|daisy|DaisyX|daisyx|Daisyx")
    & ~filters.bot
    & ~filters.via_bot
    & ~filters.forwarded
    & ~filters.reply
    & ~filters.channel
    & ~filters.edited)
async def inuka(client, message):
    msg = message.text
    if msg.startswith("/") or msg.startswith("@"):
        message.continue_propagation()
    u = msg.split()
    emj = extract_emojis(msg)
    msg = msg.replace(emj, "")
    if ([(k) for k in u if k.startswith("@")]
            and [(k) for k in u if k.startswith("#")]
Ejemplo n.º 26
0
            if not owned_fed:
                return await message.reply_text(await self.bot.text(
                    chat_id, "user-no-feds"))
            await self.feds_db.update_one({"_id": owned_fed["_id"]},
                                          {"$set": {
                                              "log": chat_id
                                          }})
            await message.reply_text(await
                                     self.bot.text(chat_id,
                                                   "fed-log-set-group",
                                                   owned_fed["name"]))
        else:
            await message.reply_text(await
                                     self.bot.text(chat_id, "err-chat-groups"))

    @listener.on(filters=filters.regex(r"logfed_(.*?)"),
                 update="callbackquery")
    async def confirm_log_fed(self, query):
        chat_id = query.message.chat.id
        user_id = query.from_user.id
        _, owner_id, fid = query.data.split("_")
        if user_id != int(owner_id):
            return await query.edit_message_text(await self.bot.text(
                chat_id, "fed-invalid-identity"))
        fed_data = await self.feds_db.find_one_and_update(
            {"_id": fid}, {"$set": {
                "log": chat_id
            }})
        await query.edit_message_text(await
                                      self.bot.text(chat_id,
                                                    "fed-log-set-chnl",
Ejemplo n.º 27
0
import os
import sys
from datetime import datetime
from userlixo.config import sudoers, user, bot
from userlixo.database import Config
from pyrogram import errors, Client, filters
from pyromod.helpers import ikb, array_chunk


@Client.on_callback_query(filters.sudoers & filters.regex('^setting_env'))
async def on_setting_env(c, cq):
    if cq.message:
        cq.message.chat.cancel_listener()
    lang = cq._lang
    buttons = []
    async for row in Config.all():
        btn = (f'👁‍🗨 {row.key}', f'view_env {row.key}')
        if cq.message and cq.message.from_user.id == bot.me.id:
            btn = (f'📝 {row.key}', f'edit_env {row.key}')
        buttons.append(btn)
    lines = array_chunk(buttons, 2)
    lines.append([(lang.back, 'settings')])
    keyboard = ikb(lines)
    await cq.edit(lang.settings_env_text, keyboard)


@Client.on_callback_query(filters.sudoers
                          & filters.regex('^edit_env (?P<key>.+)'))
async def on_edit(c, cq):
    lang = cq._lang
    key = cq.matches[0]['key']
Ejemplo n.º 28
0
class Federation(plugin.Plugin, FedBase):
    name = "Federations"
    helpable = True

    @listener.on("newfed")
    async def new_fed(self, message):
        """Create a new federations"""
        chat_id = message.chat.id
        if message.chat.type != "private":
            return await message.reply_text(await self.bot.text(
                chat_id, "error-chat-not-private"))

        if message.command:
            fed_name = (" ".join(message.command)).strip()
            fed_id = rand_key()
            owner_id = message.from_user.id

            check = await self.feds_db.find_one({"owner": owner_id})
            if check:
                return await message.reply_text(await self.bot.text(
                    chat_id, "federeation-limit"))

            async with self.lock:
                await self.feds_db.insert_one({
                    "_id": fed_id,
                    "name": fed_name,
                    "owner": owner_id,
                    "log": owner_id
                })
            LOGGER.debug(
                f"Created new fed {fed_name}({fed_id}) by {message.from_user.username}"
            )
            text = await self.bot.text(chat_id,
                                       "new-federation",
                                       fed_name=fed_name,
                                       fed_id=fed_id)
            await asyncio.gather(
                message.reply_text(text),
                self.bot.channel_log(
                    f"Created new federation **{fed_name}** with ID: **{fed_id}**"
                ),
            )
        else:
            await message.reply_text(await
                                     self.bot.text(chat_id, "need-fed-name"))

    @listener.on("delfed")
    async def del_fed(self, message):
        """Delete federations"""
        chat_id = message.chat.id
        if message.chat.type != "private":
            return await message.reply_text(await self.bot.text(
                chat_id, "error-chat-not-private"))

        user_id = message.from_user.id
        feds = await self.feds_db.find_one({"owner": user_id})
        if not feds:
            return await message.reply_text(await self.bot.text(
                chat_id, "user-no-feds"))

        await message.reply_text(
            await self.bot.text(chat_id, "del-fed-confirm", feds["name"]),
            reply_markup=InlineKeyboardMarkup([
                [
                    InlineKeyboardButton(
                        text=await self.bot.text(chat_id, "fed-confirm-text"),
                        callback_data=f"rmfed_{feds['_id']}",
                    )
                ],
                [
                    InlineKeyboardButton(
                        text=await self.bot.text(chat_id, "fed-abort-text"),
                        callback_data="rmfed_abort",
                    )
                ],
            ]),
        )

    @listener.on(filters=filters.regex(r"rmfed_(.*?)"), update="callbackquery")
    async def del_fed_query(self, query):
        """Delete federation button listener"""
        chat_id = query.message.chat.id
        fed_id = query.data.split("_")[1]
        if fed_id == "abort":
            return await query.message.edit_text(await self.bot.text(
                chat_id, "fed-delete-canceled"))
        LOGGER.debug(f"Deleting federation {fed_id}")
        async with self.lock:
            data = await self.feds_db.find_one_and_delete({"_id": fed_id})
        await query.message.edit_text(await
                                      self.bot.text(chat_id, "fed-delete-done",
                                                    data["name"]))

    @listener.on("joinfed", admin_only=True)
    async def join_fed(self, message):
        """Join a federation in chats"""
        chat_id = message.chat.id
        user_id = message.from_user.id
        admins = await message.chat.get_member(user_id)
        if not (admins.status == "creator"
                or user_id == self.bot.staff["owner"]):
            return await message.reply_text(await self.bot.text(
                chat_id, "err-group-creator-cmd"))

        if message.command:
            if await self.get_fed_bychat(chat_id):
                return await message.reply_text(await self.bot.text(
                    chat_id, "fed-cant-two-feds"))
            fid = message.command[0]
            fdata = await self.get_fed(fid)
            if not fdata:
                return await message.reply_text(await self.bot.text(
                    chat_id, "fed-invalid-id"))
            if chat_id in fdata.get("chats", []):
                return await message.reply_text(await self.bot.text(
                    chat_id, "fed-already-connected"))

            async with self.lock:
                await self.feds_db.update_one({"_id": fid},
                                              {"$push": {
                                                  "chats": chat_id
                                              }})
            await message.reply_text(await
                                     self.bot.text(chat_id,
                                                   "fed-chat-joined-info",
                                                   fdata["name"]))
            if flog := fdata.get("log", None):
                await self.bot.client.send_message(flog, "")
Ejemplo n.º 29
0
            reply_markup=buttons,
        )
        await message.delete()
    else:
        bot = await userge.bot.get_me()
        x = await userge.get_inline_bot_results(bot.username, f"ytdl {input_url}")
        await message.delete()
        await userge.send_inline_bot_result(
            chat_id=message.chat.id, query_id=x.query_id, result_id=x.results[0].id
        )


if userge.has_bot:

    @userge.bot.on_callback_query(
        filters.regex(pattern=r"^ytdl_download_(.*)_([\d]+|mkv|mp4|mp3)(?:_(a|v))?")
    )
    @check_owner
    async def ytdl_download_callback(c_q: CallbackQuery):
        yt_code = c_q.matches[0].group(1)
        choice_id = c_q.matches[0].group(2)
        downtype = c_q.matches[0].group(3)
        if str(choice_id).isdigit():
            choice_id = int(choice_id)
            if choice_id == 0:
                await c_q.answer("🔄  Processing...", show_alert=False)
                await c_q.edit_message_reply_markup(
                    reply_markup=(await download_button(yt_code))
                )
                return
        startTime = time()
Ejemplo n.º 30
0
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import anilist
from pyrogram import filters
from pyrogram.types import CallbackQuery
from pyromod.helpers import ikb
from pyromod.nav import Pagination

from amime.amime import Amime
from amime.database import Favorites


@Amime.on_callback_query(filters.regex(r"favorites manga (?P<page>\d+)"))
async def manga_favorites(bot: Amime, callback: CallbackQuery):
    page = int(callback.matches[0]["page"])

    message = callback.message
    user = callback.from_user
    lang = callback._lang

    keyboard = []
    async with anilist.AsyncClient() as client:
        favorites = await Favorites.filter(user=user.id, type="manga")

        results = []
        for favorite in favorites:
            manga = await client.get(favorite.item, "manga")
            results.append((favorite, manga))