示例#1
0
    async def vol_callback(cq: CallbackQuery):

        arg = cq.matches[0].group(1)
        volume = 0

        if arg.isnumeric():
            volume = int(arg)

        elif arg == "custom":

            try:
                async with userge.conversation(cq.message.chat.id, user_id=cq.from_user.id) as conv:
                    await cq.edit_message_text("`Now Input Volume`")

                    def _filter(_, __, m: RawMessage) -> bool:
                        r = m.reply_to_message
                        return r and r.message_id == cq.message.message_id

                    response = await conv.get_response(mark_read=True,
                                                       filters=filters.create(_filter))
            except StopConversation:
                await cq.edit_message_text("No arguments passed!")
                return

            if response.text.isnumeric():
                volume = int(response.text)
            else:
                await cq.edit_message_text("`Invalid Arguments!`")
                return

        if 200 >= volume > 0:
            await call.set_my_volume(volume)
            await cq.edit_message_text(f"Successfully set volume to {volume}")
        else:
            await cq.edit_message_text("`Invalid Range!`")
示例#2
0
 async def broadcast(msg: PyroMessage):
     global IN_CONVO  # pylint: disable=global-statement
     if len(_USERS) < 1:
         return await bot.send_message(msg.chat.id,
                                       "No one Started your bot. 🤭")
     IN_CONVO = True
     temp_msgs = []
     async with userge.bot.conversation(
             msg.chat.id, timeout=30,
             limit=7) as conv:  # 5 post msgs and 2 command msgs
         await conv.send_message(MESSAGE)
         filter_ = filters.create(
             lambda _, __, ___: filters.incoming & ~filters.edited)
         while True:
             response = await conv.get_response(filters=filter_)
             if response.text and response.text.startswith("/cancel"):
                 IN_CONVO = False
                 return await msg.reply("Broadcast process Cancelled.")
             if len(temp_msgs) >= 1 and response.text == "/done":
                 break
             if len(temp_msgs) >= 1 and response.text == "/preview":
                 conv._count -= 1
                 for i in temp_msgs:
                     if i.poll:
                         await conv.send_message("Poll Message.")
                         continue
                     await i.copy(conv.chat_id)
                 await conv.send_message(
                     CONTINUE_MESSAGE.format(PREVIEW_MESSAGE))
                 continue
             if len(temp_msgs) >= 5:
                 raise StopConversation("message limit reached!")
             temp_msgs.append(response)
             await response.copy(conv.chat_id)
             await conv.send_message(CONTINUE_MESSAGE.format(NEXT_MESSAGE))
         confirm_text = CONFIRM_TEXT.format(len(temp_msgs))
         await conv.send_message(confirm_text)
         response = await conv.get_response(filters=filter_)
         while True:
             if response.text == "/send":
                 await send_broadcast_post(msg, temp_msgs)
                 IN_CONVO = False
                 return
             if response.text == "/cancel":
                 await conv.send_message("Broadcast process Cancelled.")
                 IN_CONVO = False
                 return
             conv._count -= 1
             await conv.send_message("Invalid Arguments!")
             await conv.send_message(confirm_text)
             response = await conv.get_response(filters=filter_)
示例#3
0
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

import asyncio
from typing import Dict

from userge import userge, Message, filters, get_collection

FILTERS_COLLECTION = get_collection("filters")
CHANNEL = userge.getCLogger(__name__)

FILTERS_DATA: Dict[int, Dict[str, int]] = {}
FILTERS_CHATS = filters.create(
    lambda _, __, query: query.chat.id in FILTERS_DATA)

_SUPPORTED_TYPES = (":audio:", ":video:", ":photo:", ":document:", ":sticker:",
                    ":animation:", ":voice:", ":video_note:", ":media:",
                    ":game:", ":contact:", ":location:", ":venue:",
                    ":web_page:", ":poll:", ":via_bot:", ":forward_date:",
                    ":mentioned:", ":service:", ":media_group_id:",
                    ":game_high_score:", ":pinned_message:",
                    ":new_chat_title:", ":new_chat_photo:",
                    ":delete_chat_photo:")


def _filter_updater(chat_id: int, name: str, message_id: int) -> None:
    if chat_id in FILTERS_DATA:
        FILTERS_DATA[chat_id].update({name: message_id})
    else:
示例#4
0
#
# All rights reserved.

import time
import asyncio
from random import choice, randint

from userge import userge, Message, filters, Config, get_collection
from userge.utils import time_formatter

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
AFK_COLLECTION = get_collection("AFK")

IS_AFK = False
IS_AFK_FILTER = filters.create(lambda _, __, ___: bool(IS_AFK))
REASON = ''
TIME = 0.0
USERS = {}


async def _init() -> None:
    global IS_AFK, REASON, TIME  # pylint: disable=global-statement
    data = await SAVED_SETTINGS.find_one({'_id': 'AFK'})
    if data:
        IS_AFK = data['on']
        REASON = data['data']
        TIME = data['time'] if 'time' in data else 0
    async for _user in AFK_COLLECTION.find():
        USERS.update(
            {_user['_id']: [_user['pcount'], _user['gcount'], _user['men']]})
示例#5
0
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

import asyncio
from typing import Dict

from userge import userge, filters, Message, Config, get_collection
from userge.utils import SafeDict

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
ALLOWED_COLLECTION = get_collection("PM_PERMIT")

pmCounter: Dict[int, int] = {}
allowAllFilter = filters.create(lambda _, __, ___: Config.ALLOW_ALL_PMS)
noPmMessage = bk_noPmMessage = (
    "Hello {fname} this is an automated message\n"
    "Please wait until you get approved to direct message "
    "And please dont spam until then ")
blocked_message = bk_blocked_message = "**You were automatically blocked**"


async def _init() -> None:
    global noPmMessage, blocked_message  # pylint: disable=global-statement
    async for chat in ALLOWED_COLLECTION.find({"status": 'allowed'}):
        Config.ALLOWED_CHATS.add(chat.get("_id"))
    _pm = await SAVED_SETTINGS.find_one({'_id': 'PM GUARD STATUS'})
    if _pm:
        Config.ALLOW_ALL_PMS = bool(_pm.get('data'))
    _pmMsg = await SAVED_SETTINGS.find_one({'_id': 'CUSTOM NOPM MESSAGE'})
示例#6
0
                            InlineKeyboardButton,
                            InlineQueryResultArticle,
                            InputTextMessageContent,
                            CallbackQuery,
                            InlineQuery)

from userge import userge, config, filters, Message, get_collection
from userge.utils import SafeDict
from .. import pmpermit

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
ALLOWED_COLLECTION = get_collection("PM_PERMIT")

pmCounter: Dict[int, int] = {}
allowAllFilter = filters.create(lambda _, __, ___: pmpermit.Dynamic.ALLOW_ALL_PMS)
noPmMessage = bk_noPmMessage = ("Hello {fname} this is an automated message\n"
                                "Please wait until you get approved to direct message "
                                "And please dont spam until then ")
blocked_message = bk_blocked_message = "**You were automatically blocked**"


@userge.on_start
async def _init() -> None:
    global noPmMessage, blocked_message  # pylint: disable=global-statement
    async for chat in ALLOWED_COLLECTION.find({"status": 'allowed'}):
        pmpermit.ALLOWED_CHATS.add(chat.get("_id"))
    _pm = await SAVED_SETTINGS.find_one({'_id': 'PM GUARD STATUS'})
    if _pm:
        pmpermit.Dynamic.ALLOW_ALL_PMS = bool(_pm.get('data'))
    i_pm = await SAVED_SETTINGS.find_one({'_id': 'INLINE_PM_PERMIT'})
示例#7
0
import time
from random import choice, randint

from pyrogram import enums

from userge import userge, Message, filters, get_collection
from userge.utils import time_formatter, get_custom_import_re

pmpermit = get_custom_import_re("userge.plugins.utils.pmpermit", False)

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
AFK_COLLECTION = get_collection("AFK")

IS_AFK = False
IS_AFK_FILTER = filters.create(lambda _, __, ___: bool(IS_AFK))
AFK_INCOMING_FILTER = (
    IS_AFK_FILTER & ~filters.me & ~filters.bot & ~filters.service)
if pmpermit is not None:
    AFK_PM_FILTER = (filters.private & (
        filters.create(
            lambda _, __, ___: pmpermit.Dynamic.ALLOW_ALL_PMS) | pmpermit.ALLOWED_CHATS))
    AFK_INCOMING_FILTER &= (filters.mentioned | AFK_PM_FILTER)
else:
    AFK_INCOMING_FILTER &= filters.mentioned
REASON = ''
TIME = 0.0
USERS = {}


@userge.on_start
示例#8
0
BANNED_USERS = get_collection("BANNED_USERS")
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 _, __, ___: ___.chat.id in _BANNED_USERS)


@userge.on_start
async def _init():
    global START_TEXT, BOT_PM  # pylint: disable=global-statement
    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():
示例#9
0
DB = get_collection("BAN_CHANNELS")


@userge.on_start
async def _init() -> None:
    async for chat in DB.find():
        chat_id = chat['chat_id']
        if chat['enabled']:
            gadmin.ENABLED_CHATS.append(chat_id)
            if chat['ban']:
                gadmin.BAN_CHANNELS.append(chat_id)
        gadmin.ALLOWED[chat_id] = chat['allowed']


channel_delete = filters.create(
    lambda _, __, query: (query.chat and query.sender_chat and query.chat.id in
                          gadmin.ENABLED_CHATS))


@userge.on_cmd(
    "promote",
    about={
        'header':
        "use this to promote group members",
        'description':
        "Provides admin rights to the person in the supergroup.\n"
        "you can also add custom title while promoting new admin.\n"
        "[NOTE: Requires proper admin rights in the chat!!!]",
        'examples': [
            "{tr}promote [username | userid] or [reply to user] :custom title (optional)",
            "{tr}promote @someusername/userid/replytouser Staff (custom title)"
示例#10
0
#
# All rights reserved.

import time
import asyncio
from random import choice, randint

from userge import userge, Message, filters, Config, get_collection
from userge.utils import time_formatter

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
AFK_COLLECTION = get_collection("AFK")

IS_AFK = False
IS_AFK_FILTER = filters.create(lambda _, __, ___: bool(IS_AFK))
REASON = ''
TIME = 0.0
USERS = {}


async def _init() -> None:
    global IS_AFK, REASON, TIME  # pylint: disable=global-statement
    data = await SAVED_SETTINGS.find_one({'_id': 'AFK'})
    if data:
        IS_AFK = data['on']
        REASON = data['data']
        TIME = data['time'] if 'time' in data else 0
    async for _user in AFK_COLLECTION.find():
        USERS.update({_user['_id']:  [_user['pcount'], _user['gcount'], _user['men']]})
示例#11
0
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/UsergeTeam/Userge/blob/master/LICENSE >
#
# All rights reserved.

# By @AsmSafone

import os

from userge import userge, Message, filters, config, get_collection
from ...utils import ocr

IS_ENABLED = False
IS_ENABLED_FILTER = filters.create(lambda _, __, ___: IS_ENABLED)

USER_DATA = get_collection("CONFIGS")
CHANNEL = userge.getCLogger(__name__)


@userge.on_start
async def _init() -> None:
    global IS_ENABLED  # pylint: disable=global-statement
    data = await USER_DATA.find_one({'_id': 'AUTO_FASTLY'})
    if data:
        IS_ENABLED = data['on']


@userge.on_cmd("autofastly", about={
    'header': "Auto Fastly Response",
示例#12
0
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/UsergeTeam/Userge/blob/master/LICENSE >
#
# All rights reserved.

from uuid import uuid4

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",
示例#13
0
""" setup AFK mode """

import asyncio
import time
from random import choice, randint

from userge import Config, Message, filters, get_collection, userge
from userge.utils import time_formatter

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
AFK_COLLECTION = get_collection("AFK")

IS_AFK = False
IS_AFK_FILTER = filters.create(lambda _, __, ___: bool(IS_AFK))
REASON = ""
TIME = 0.0
USERS = {}


async def _init() -> None:
    global IS_AFK, REASON, TIME  # pylint: disable=global-statement
    data = await SAVED_SETTINGS.find_one({"_id": "AFK"})
    if data:
        IS_AFK = data["on"]
        REASON = data["data"]
        TIME = data["time"] if "time" in data else 0
    async for _user in AFK_COLLECTION.find():
        USERS.update(
            {_user["_id"]: [_user["pcount"], _user["gcount"], _user["men"]]})
示例#14
0
    async def broadcast(msg: PyroMessage):
        global IN_CONVO  # pylint: disable=global-statement
        if len(_USERS) < 1:
            return await bot.send_message(msg.chat.id,
                                          "No one Started your bot. 🤭")
        IN_CONVO = True
        MESSAGE = f"""
A broadcast post will be sent to {len(_USERS)} users.

Send one or multiple messages you want to include in the post.
It can be anything — a text, photo, video, even a sticker.

Type /cancel to cancel the operation.
        """
        NEXT_MESSAGE = "This message has been added to the post."
        PREVIEW_MESSAGE = "The post preview sent above."
        CONTINUE_MESSAGE = (
            """{} You can continue to send messages. Type /done to send this broadcast post.
            
/preview — preview the broadcast post
/cancel - cancel the current operation """)
        temp_msgs = []
        async with userge.bot.conversation(
                msg.chat.id, timeout=30,
                limit=7) as conv:  # 5 post msgs and 2 command msgs
            await conv.send_message(MESSAGE)
            filter = filters.create(
                lambda _, __, ___: filters.incoming & ~filters.edited)
            while True:
                response = await conv.get_response(filters=filter)
                if response.text.startswith("/cancel"):
                    IN_CONVO = False
                    return await msg.reply("Broadcast process Cancelled.")
                if len(temp_msgs) >= 1 and response.text == "/done":
                    break
                if len(temp_msgs) >= 1 and response.text == "/preview":
                    conv._count -= 1
                    for i in temp_msgs:
                        if i.poll:
                            await conv.send_message("Poll Message.")
                            continue
                        await i.copy(conv.chat_id)
                    await conv.send_message(
                        CONTINUE_MESSAGE.format(PREVIEW_MESSAGE))
                    continue
                if len(temp_msgs) >= 5:
                    return await conv.send_message(
                        "You can only send 5 post message at once.")
                temp_msgs.append(response)
                await response.copy(conv.chat_id)
                await conv.send_message(CONTINUE_MESSAGE.format(NEXT_MESSAGE))
            COFIRM_TEXT = f"""
Are you sure you want to send {len(temp_msgs)} in broadcast post?

Type /send to confirm or /cancel to exit.
            """
            await conv.send_message(COFIRM_TEXT)
            response = await conv.get_response(filters=filter)
            while True:
                if response.text == "/send":
                    await send_broadcast_post(msg, temp_msgs)
                    IN_CONVO = False
                    return
                if response.text == "/cancel":
                    await conv.send_message("Broadcast process Cancelled.")
                    IN_CONVO = False
                    return
                conv._count -= 1
                await conv.send_message("Invalid Arguments!")
                await conv.send_message(COFIRM_TEXT)
                response = await conv.get_response(filters=filter)
示例#15
0
BANNED_USERS = get_collection("BANNED_USERS")
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":