Exemplo n.º 1
0
import os
import glob
from pathlib import Path
from time import time
from math import floor

import wget
import youtube_dl as ytdl

from xdecha import xdecha, Message, Config, pool
from xdecha.utils import time_formatter, humanbytes
from .upload import upload

LOGGER = xdecha.getLogger(__name__)


@xdecha.on_cmd("ytinfo",
               about={
                   'header': "Get info from ytdl",
                   'description':
                   'Get information of the link without downloading',
                   'examples': '{tr}ytinfo link',
                   'others':
                   'To get info about direct links, use `{tr}head link`'
               })
async def ytinfo(message: Message):
    """ get info from a link """
    await message.edit("Hold on \u23f3 ..")
    _exracted = await _yt_getInfo(message.input_or_reply_str)
    if isinstance(_exracted, ytdl.utils.YoutubeDLError):
        await message.err(str(_exracted))
Exemplo n.º 2
0
import json
from emoji import get_emoji_regexp

import aiohttp

from xdecha import xdecha, Message, Config

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


@xdecha.on_cmd("cr",
               about={
                   'header':
                   "use this to convert currency & get exchange rate",
                   'description': "Convert currency & get exchange rates.",
                   'examples': "{tr}cr 1 BTC USD"
               })
async def cur_conv(message: Message):
    """
    this function can get exchange rate results
    """
    if Config.CURRENCY_API is None:
        await message.edit(
            "<code>Oops!!get the API from</code> "
            "<a href='https://free.currencyconverterapi.com'>HERE</a> "
            "<code>& add it to Heroku config vars</code> (<code>CURRENCY_API</code>)",
            disable_web_page_preview=True,
            parse_mode="html",
            del_in=0)
        return
Exemplo n.º 3
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: