Пример #1
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",
Пример #2
0
import aiohttp

from xdecha import xdecha, Message

LOG = xdecha.getLogger(__name__)  # logger object
CHANNEL = xdecha.getCLogger(__name__)  # channel logger object


@xdecha.on_cmd("dic",
               about={
                   'header': "English Dictionary-telegram",
                   'usage': "{tr}dic [word]",
                   'examples': 'word : Search for any word'
               })
async def dictionary(message: Message):
    """this is a dictionary"""
    LOG.info("starting dic command...")
    input_ = message.input_str

    await message.edit("`processing...⚙️🛠`")

    def combine(s_word, name):
        w_word = f"🛑--**__{name.title()}__**--\n"
        for i in s_word:
            if "definition" in i:
                if "example" in i:
                    w_word += ("\n👩‍🏫 **Definition** 👨‍🏫\n<pre>" +
                               i["definition"] +
                               "</pre>\n\t\t❓<b>Example</b>❔\n<pre>" +
                               i["example"] + "</pre>")
                else: