Example #1
0
import os
import base64
import asyncio
import datetime
import textwrap
from shutil import copyfile

import aiofiles
from PIL import Image, ImageFont, ImageDraw

from xdecha import xdecha, Message, Config, get_collection

SAVED_SETTINGS = get_collection("CONFIGS")
UPDATE_PIC = False
BASE_PIC = "resources/base_profile_pic.jpg"
MDFY_PIC = "resources/mdfy_profile_pic.jpg"
LOG = xdecha.getLogger(__name__)


async def _init() -> None:
    global UPDATE_PIC  # pylint: disable=global-statement
    data = await SAVED_SETTINGS.find_one({'_id': 'UPDATE_PIC'})
    if data:
        UPDATE_PIC = data['on']
        if not os.path.exists(BASE_PIC):
            with open(BASE_PIC, "wb") as media_file_:
                media_file_.write(base64.b64decode(data['media']))


@xdecha.on_cmd(
    "autopic", about={
Example #2
0
import time
import asyncio
from random import choice, randint

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

CHANNEL = xdecha.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']]})


@xdecha.on_cmd("afk", about={
    'header': "Set to AFK mode",
Example #3
0
import asyncio
from typing import Dict
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
from pyrogram.errors import BotInlineDisabled

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

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

pmCounter: Dict[int, int] = {}
_IS_INLINE = True
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, _IS_INLINE  # 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'))
    i_pm = await SAVED_SETTINGS.find_one({'_id': 'INLINE_PM_PERMIT'})
    if i_pm:
Example #4
0
import asyncio

from pyrogram.errors.exceptions.bad_request_400 import PeerIdInvalid

from xdecha import xdecha, Message, Config, get_collection

SAVED_SETTINGS = get_collection("CONFIGS")
SUDO_USERS_COLLECTION = get_collection("sudo_users")
SUDO_CMDS_COLLECTION = get_collection("sudo_cmds")


async def _init() -> None:
    s_o = await SAVED_SETTINGS.find_one({'_id': 'SUDO_ENABLED'})
    if s_o:
        Config.SUDO_ENABLED = s_o['data']
    async for i in SUDO_USERS_COLLECTION.find():
        Config.SUDO_USERS.add(i['_id'])
    async for i in SUDO_CMDS_COLLECTION.find():
        Config.ALLOWED_COMMANDS.add(i['_id'])


@xdecha.on_cmd("sudo", about={'header': "enable / disable sudo access"}, allow_channels=False)
async def sudo_(message: Message):
    """ enable / disable sudo access """
    if Config.SUDO_ENABLED:
        Config.SUDO_ENABLED = False
        await message.edit("`sudo disabled !`", del_in=3)
    else:
        Config.SUDO_ENABLED = True
        await message.edit("`sudo enabled !`", del_in=3)
    await SAVED_SETTINGS.update_one(
Example #5
0
""" setup gban """

import json
import asyncio
from typing import Union

import aiohttp
import spamwatch
from spamwatch.types import Ban
from pyrogram.errors.exceptions.bad_request_400 import (ChatAdminRequired,
                                                        UserAdminInvalid,
                                                        ChannelInvalid)

from xdecha import xdecha, Message, Config, get_collection, filters, pool

SAVED_SETTINGS = get_collection("CONFIGS")
GBAN_USER_BASE = get_collection("GBAN_USER")
WHITELIST = get_collection("WHITELIST_USER")
CHANNEL = xdecha.getCLogger(__name__)
LOG = xdecha.getLogger(__name__)


async def _init() -> None:
    s_o = await SAVED_SETTINGS.find_one({'_id': 'ANTISPAM_ENABLED'})
    if s_o:
        Config.ANTISPAM_SENTRY = s_o['data']


@xdecha.on_cmd("antispam",
               about={
                   'header': "enable / disable antispam",
Example #6
0
import time
import asyncio
import shutil

from pyrogram.types import User

from xdecha.core.ext import RawClient
from xdecha import xdecha, Message, Config, get_collection
from xdecha.utils import terminate

SAVED_SETTINGS = get_collection("CONFIGS")
DISABLED_CHATS = get_collection("DISABLED_CHATS")

MAX_IDLE_TIME = 300
LOG = xdecha.getLogger(__name__)
CHANNEL = xdecha.getCLogger(__name__)


async def _init() -> None:
    global MAX_IDLE_TIME  # pylint: disable=global-statement
    d_s = await SAVED_SETTINGS.find_one({'_id': 'DYNO_SAVER'})
    if d_s:
        Config.RUN_DYNO_SAVER = bool(d_s['on'])
        MAX_IDLE_TIME = int(d_s['timeout'])
    disabled_all = await SAVED_SETTINGS.find_one({'_id': 'DISABLE_ALL_CHATS'})
    if disabled_all:
        Config.DISABLED_ALL = bool(disabled_all['on'])
    else:
        async for i in DISABLED_CHATS.find():
            if i['_id'] == Config.LOG_CHANNEL_ID:
                continue
Example #7
0
import asyncio
from typing import Dict

from xdecha import xdecha, Message, filters, get_collection

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

FILTERS_DATA: Dict[int, Dict[str, int]] = {}
FILTERS_CHATS = filters.create(
    lambda _, __, query: query.chat and 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:
        FILTERS_DATA[chat_id] = {name: message_id}


def _filter_deleter(chat_id: int, name: str) -> None:
    if chat_id in FILTERS_DATA and name in FILTERS_DATA[chat_id]:
Example #8
0
import asyncio
from typing import Dict, Tuple

from xdecha import xdecha, Message, get_collection, Config

NOTES_COLLECTION = get_collection("notes")
CHANNEL = xdecha.getCLogger(__name__)

NOTES_DATA: Dict[int, Dict[str, Tuple[int, bool]]] = {}


def _note_updater(chat_id: int, name: str, message_id: int,
                  is_global: bool) -> None:
    if chat_id in NOTES_DATA:
        NOTES_DATA[chat_id].update({name: (message_id, is_global)})
    else:
        NOTES_DATA[chat_id] = {name: (message_id, is_global)}


def _note_deleter(chat_id: int, name: str) -> None:
    if chat_id in NOTES_DATA and name in NOTES_DATA[chat_id]:
        NOTES_DATA[chat_id].pop(name)
        if not NOTES_DATA[chat_id]:
            NOTES_DATA.pop(chat_id)


def _get_notes_for_chat(chat_id: int) -> str:
    out = ''
    if chat_id in NOTES_DATA:
        for name, pack in NOTES_DATA[chat_id].items():
            mid, is_global = pack
Example #9
0
""" setup gmute """

import asyncio

from pyrogram.types import ChatPermissions
from pyrogram.errors.exceptions.bad_request_400 import ChatAdminRequired, UserAdminInvalid

from xdecha import xdecha, Config, Message, get_collection, filters

GMUTE_USER_BASE = get_collection("GMUTE_USER")
CHANNEL = xdecha.getCLogger(__name__)
LOG = xdecha.getLogger(__name__)


@xdecha.on_cmd("gmute",
               about={
                   'header':
                   "Globally Mute A User",
                   'description':
                   "Adds User to your GMute List",
                   'examples':
                   "{tr}gmute [userid | reply] [reason for gmute] (mandatory)"
               },
               allow_channels=False,
               allow_bots=False)
async def gmute_user(msg: Message):
    """ Mute a user globally """
    await msg.edit("`Globally Muting this User...`")
    user_id, reason = msg.extract_user_and_text
    if not user_id:
        await msg.edit("`no valid user_id or message specified,`"