示例#1
0
            parse_mode="html", del_in=0)
        return

    IS_ENABLED = not IS_ENABLED
    await USER_DATA.update_one({'_id': 'AUTO_FASTLY'},
                               {"$set": {'on': IS_ENABLED}}, upsert=True)
    await msg.edit(
        "Auto Fastly Response has been **{}** Successfully...".format(
            "Enabled" if IS_ENABLED else "Disabled"
        ),
        log=True, del_in=5
    )


@userge.on_filters(IS_ENABLED_FILTER & filters.group & filters.photo & filters.incoming
                   & filters.user([1806208310, 1983714367, 1877720720, 5053950120]),  # Bot IDs
                   group=-1, allow_via_bot=False)
async def fastly_handler(msg: Message):
    img = await msg.download(config.Dynamic.DOWN_PATH)
    parse = await ocr.ocr_space_file(img)
    try:
        text = parse["ParsedResults"][0]["ParsedText"]
        text = text.split("By@")[0].replace("\n", "").replace("\r", "")
        if text:
            await msg.reply_text(text.capitalize())
            await CHANNEL.log(f'Auto Fastly Responded in {msg.chat.title} [{msg.chat.id}]')
        os.remove(img)
    except Exception as e_x:  # pylint: disable=broad-except
        await CHANNEL.log(str(e_x))
        if os.path.exists(img):
            os.remove(img)
示例#2
0
            markup = InlineKeyboardMarkup([[
                InlineKeyboardButton(text="👥 UsergeTeam",
                                     url="https://github.com/UsergeTeam"),
                InlineKeyboardButton(text="🧪 Repo", url=botpm.UPSTREAM_REPO)
            ], [InlineKeyboardButton(text="🎖 GNU GPL v3.0", url=copy_)]])
            await send_start_text(msg, text, path, markup)
            return
        text = "Hey, you can configure me here."
        markup = InlineKeyboardMarkup(
            [[InlineKeyboardButton("Settings", callback_data="stngs")]])
        if len(msg.command) > 1:
            #  https://github.com/UsergeTeam/Userge/blob/alpha/userge/plugins/help.py#L104
            return
        await send_start_text(msg, text, path, markup)

    @bot.on_message(filters.user(userge_id) & ~filters.edited
                    & filters.private & filters.command("settext"),
                    group=1)
    async def set_text(_, msg: PyroMessage):
        global START_TEXT  # pylint: disable=global-statement
        text = msg.text.split(' ', maxsplit=1)[1] if ' ' in msg.text else ''
        replied = msg.reply_to_message
        if replied:
            text = replied.text or replied.caption
        if not text:
            await msg.reply("Text not found!")
        else:
            START_TEXT = text
            await SAVED_SETTINGS.update_one({"_id": "BOT_START_TEXT"},
                                            {"$set": {
                                                "data": text
示例#3
0
            {"_id": "AFK"},
            {"$set": {
                "on": True,
                "data": REASON,
                "time": TIME
            }},
            upsert=True,
        ),
    )


@userge.on_filters(
    IS_AFK_FILTER
    & ~filters.me
    & ~filters.bot
    & ~filters.user(Config.TG_IDS)
    & ~filters.edited
    & (filters.mentioned
       | (filters.private
          & ~filters.service
          & (filters.create(lambda _, __, ___: Config.ALLOW_ALL_PMS)
             | Config.ALLOWED_CHATS))),
    allow_via_bot=False,
)
async def handle_afk_incomming(message: Message) -> None:
    """handle incomming messages when you afk"""
    if not message.from_user:
        return
    user_id = message.from_user.id
    chat = message.chat
    user_dict = await message.client.get_user_dict(user_id)
示例#4
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}"
            elif 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>"
            return await msg.reply(out_str,
                                   parse_mode='html',
                                   disable_web_page_preview=True)
        await send_start_text(msg, text, path, markup)

    @bot.on_message(filters.user(userge_id) & filters.private
                    & filters.command("settext"),
                    group=1)
    async def set_text(_, msg: PyroMessage):
        global START_TEXT  # pylint: disable=global-statement
        text = msg.text.split(' ', maxsplit=1)[1] if ' ' in msg.text else ''
        replied = msg.reply_to_message
        if replied:
            text = replied.text or replied.caption
        if not text:
            await msg.reply("Text not found!")
        else:
            START_TEXT = text
            await SAVED_SETTINGS.update_one({"_id": "BOT_START_TEXT"},
                                            {"$set": {
                                                "data": text
示例#5
0
from pyrogram.types import (CallbackQuery, InlineQuery, InlineKeyboardButton,
                            InlineQueryResultArticle, InputTextMessageContent,
                            InlineKeyboardMarkup)
from pyrogram.types import Message as PyroMessage
from userge import userge, filters, config

PRVT_MSGS = {}
FILTER = filters.create(lambda _, __, q: '-' in q.query and q.from_user and q.
                        from_user.id in config.OWNER_ID)
MEDIA_FID_S = {}
DEEP_LINK_FLITER = filters.private & filters.create(
    lambda _, __, msg: msg.text and msg.text.startswith("/start prvtmsg"))


@userge.bot.on_message(
    filters.user(list(config.OWNER_ID)) & ~filters.edited
    & filters.command("secretmsg", config.SUDO_TRIGGER))
async def recv_s_m_o(_, msg: PyroMessage):
    replied = msg.reply_to_message
    if not replied:
        return await msg.reply_text("reply to a message")
    media_type = replied.media
    if media_type and media_type in [
            "contact",
            "dice",
            "poll",
            "location",
            "venue",
    ]:
        await msg.reply_text("invalid media type")
        return
示例#6
0
                            InlineKeyboardMarkup)
from pyrogram.types import Message as PyroMessage
from pyrogram import enums

from userge import userge, filters, config

PRVT_MSGS = {}
FILTER = filters.create(lambda _, __, q: '-' in q.query and q.from_user and q.
                        from_user.id in config.OWNER_ID)
MEDIA_FID_S = {}
DEEP_LINK_FLITER = filters.private & filters.create(
    lambda _, __, msg: msg.text and msg.text.startswith("/start prvtmsg"))


@userge.bot.on_message(
    filters.user(list(config.OWNER_ID))
    & filters.command("secretmsg", config.SUDO_TRIGGER))
async def recv_s_m_o(_, msg: PyroMessage):
    replied = msg.reply_to_message
    if not replied:
        return await msg.reply_text("reply to a message")
    media_type = replied.media
    if media_type and media_type in [
            enums.MessageMediaType.CONTACT,
            enums.MessageMediaType.DICE,
            enums.MessageMediaType.POLL,
            enums.MessageMediaType.LOCATION,
            enums.MessageMediaType.VENUE,
    ]:
        await msg.reply_text("invalid media type")
        return
示例#7
0
            markup = InlineKeyboardMarkup([[
                InlineKeyboardButton(text="👥 UsergeTeam",
                                     url="https://github.com/UsergeTeam"),
                InlineKeyboardButton(text="🧪 Repo", url=botpm.UPSTREAM_REPO)
            ], [InlineKeyboardButton(text="🎖 GNU GPL v3.0", url=copy_)]])
            await send_start_text(msg, text, path, markup)
            return
        text = "Hey, you can configure me here."
        markup = InlineKeyboardMarkup(
            [[InlineKeyboardButton("Settings", callback_data="stngs")]])
        if len(msg.command) > 1:
            #  https://github.com/UsergeTeam/Userge/blob/alpha/userge/plugins/help.py#L104
            return
        await send_start_text(msg, text, path, markup)

    @bot.on_message(filters.user(userge_id)
                    & filters.private & filters.command("settext"),
                    group=1)
    async def set_text(_, msg: PyroMessage):
        global START_TEXT  # pylint: disable=global-statement
        text = msg.text.split(' ', maxsplit=1)[1] if ' ' in msg.text else ''
        replied = msg.reply_to_message
        if replied:
            text = replied.text or replied.caption
        if not text:
            await msg.reply("Text not found!")
        else:
            START_TEXT = text
            await SAVED_SETTINGS.update_one({"_id": "BOT_START_TEXT"},
                                            {"$set": {
                                                "data": text
示例#8
0
U_ID_F_M_ID = get_collection("USER_ID_FROM_MESSAGE_ID")
STATS = get_collection("BOT_PM_STATS")
SAVED_SETTINGS = get_collection("CONFIGS")

BOT_PM: bool = False
IN_CONVO: bool = False
_USERS: List[int] = []
_HAVE_BLOCKED: List[int] = []
_BANNED_USERS: List[int] = []
_U_ID_F_M_ID: Dict[int, int] = {}
_STATS: Dict[str, int] = {"incoming": 0, "outgoing": 0}

START_TEXT = " Hello {mention}, you can contact me using this Bot."

botPmFilter = filters.create(lambda _, __, ___: BOT_PM)
bannedFilter = filters.create(lambda _, __, ___: filters.user(_BANNED_USERS))


async def _init():
    global _BANNED_USERS, START_TEXT, _USERS, _HAVE_BLOCKED, BOT_PM  # noqa
    async for a in HAVE_BLOCKED.find():
        _HAVE_BLOCKED.append(a['user_id'])
    async for b in BANNED_USERS.find():
        _BANNED_USERS.append(b['user_id'])
    async for c in USERS.find():
        _USERS.append(c["user_id"])
    async for d in U_ID_F_M_ID.find():
        _U_ID_F_M_ID[d['msg_id']] = d['user_id']
    async for e in STATS.find():
        if e.get("_id") == "INCOMING_STATS":
            _STATS['incoming'] = e.get("data")
示例#9
0
from userge import userge, Message, filters


LOG = userge.getLogger(__name__)
CHANNEL = userge.getCLogger(__name__)
AFK = []
FIX = ""
FK = ""
CHAT = [-1001199769918, -1001360580171, -1001486172777]  # rdl
WW = [1029642148, 980444671, 618096097, 175844556, 738172950, 1569645653]  # werewolf bots


@userge.on_filters(
    (
        filters.chat(CHAT) &
        filters.user(WW) &
        filters.regex("Tempo total do jogo|Duração da partida")
    )
)
async def auto_fk(message: Message):
    global AFK
    global FK
    if await is_sr(message):
        FK = ""
        return
    lines = message.text
    lines_count = len(lines.split("\n\n")[0].split("\n")) - 1
    info = await userge.send_message(message.chat.id, "Obtendo FK.")
    try:
        deads = await build_list(lines)
        deads = [dead for dead in deads if dead not in AFK]