コード例 #1
0
import time
import asyncio
import shutil

from userbot import userbot, Message, Config

LOG = userbot.getLogger(__name__)


@userbot.on_cmd('restart', about={
    'header': "Restarts the bot and reload all plugins",
    'flags': {
        '-h': "restart heroku dyno",
        '-t': "clean temp loaded plugins",
        '-d': "clean working folder"},
    'usage': "{tr}restart [flag | flags]",
    'examples': "{tr}restart -t -d"}, del_pre=True)
async def restart_cmd_handler(message: Message):
    await message.edit("Restarting Userbot Services", log=__name__)
    LOG.info("USERBOT Services - Restart initiated")
    if 't' in message.flags:
        shutil.rmtree(Config.TMP_PATH, ignore_errors=True)
    if 'd' in message.flags:
        shutil.rmtree(Config.DOWN_PATH, ignore_errors=True)
    if Config.HEROKU_APP and 'h' in message.flags:
        await message.edit(
            '`Heroku app found, trying to restart dyno...\nthis will take upto 30 sec`', del_in=3)
        Config.HEROKU_APP.restart()
        time.sleep(30)
    else:
        await message.edit("finalizing...", del_in=1)
コード例 #2
0
import os
import time
import math
import asyncio
from datetime import datetime
from urllib.parse import unquote_plus

from pySmartDL import SmartDL

from userbot import userbot, Message, Config
from userbot.utils import progress, humanbytes

LOGGER = userbot.getLogger(__name__)


@userbot.on_cmd(
    "download",
    about={
        'header':
        "Download files to server",
        'usage':
        "{tr}download [url | reply to telegram media]",
        'examples':
        "{tr}download https://speed.hetzner.de/100MB.bin | testing upload.bin"
    })
async def down_load_media(message: Message):
    await message.edit("Trying to Download...")
    if not os.path.isdir(Config.DOWN_PATH):
        os.mkdir(Config.DOWN_PATH)
    if message.reply_to_message and message.reply_to_message.media:
        start_t = datetime.now()
コード例 #3
0
ファイル: dic.py プロジェクト: ohskiller/tg-ubot
import requests
from userbot import userbot, Message

LOG = userbot.getLogger(__name__)  # logger object

CHANNEL = userbot.getCLogger(__name__)  # channel logger object


@userbot.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: