Пример #1
0
from vkbottle import Message

from nicevk.api import user, commands

import subprocess

commands.append(".neofetch - show neofetch output")


@user.on.message_handler(text=".neofetch")
async def help_(ans: Message):
    rst = subprocess.run(
        ["neofetch", "os", "distro", "uptime", "disk", "wm", "memory"],
        capture_output=True,
    )

    await ans.api.messages.edit(ans.peer_id, ans.id, rst.stdout.decode("utf-8"))
Пример #2
0
import asyncio
from vkbottle import Message
from nicevk.api import user, commands

commands.append(".type <text> - just typing the text")


@user.on.message_handler(text=".type <text>")
async def help_(ans: Message, text: str):
    if not text:
        return await ans.api.messages.edit(
            ans.peer_id, ans.id, "I need something to type"
        )
    if " " in text:  # to prevent messageWasntModified error
        text = text.replace(" ", "ᅠ")  # invisible char
    else:
        pass

    mes = ""
    for char in text:
        mes += "|"
        await ans.api.messages.edit(ans.peer_id, ans.id, mes)
        await asyncio.sleep(0.04)
        mes = mes[:-1] + char
        await ans.api.messages.edit(ans.peer_id, ans.id, mes)
        await asyncio.sleep(0.02)
Пример #3
0
import wget
import runpy

from datetime import datetime
from vkbottle import Message
from nicevk.api import user, commands, nicevk_folder

commands.append(".dl_mod <url> - download and execute plugin")


@user.on.message_handler(text=".dl_mod <url>")
async def help_(ans: Message, url: str):
    await ans.api.messages.edit(ans.peer_id, ans.id, f"Downloading...")

    out_path = (nicevk_folder /
                f"module_{datetime.now().isoformat().replace('.', ' ')}.py")
    wget.download(url.strip(), out=out_path)
    runpy.run_path(out_path)

    await ans.api.messages.edit(ans.peer_id, ans.id,
                                f"Downloaded and loaded the plugin")
Пример #4
0
from vkbottle import Message

from nicevk.api import user, commands

commands.append(".spam <amount> <text> - spam chat with messages")


@user.on.message_handler(text=".spam <amount> <text>")
async def help_(ans: Message, amount: str, text: str):
    amount = int(amount)
    await user.api.messages.delete(ans.id, delete_for_all=True)
    for i in range(amount):
        await ans(text)
Пример #5
0
import asyncio
import subprocess

from functools import wraps
from vkbottle import Message, VKError
from nicevk.api import user, commands, state, save_state, coro

commands.append(".restart - restart nicevk")


@coro
async def on_start():
    if (
        state.get("restart", None) is not None
        and state["restart"]["last_message"] is not None
    ):
        try:
            await user.api.messages.edit(
                *state["restart"]["last_message"], "Successfully restarted nicevk"
            )
        except VKError:
            pass
        state["restart"]["last_message"] = None
        save_state()


@user.on.message_handler(text=".restart")
async def help_(ans: Message):
    state["restart"] = {}
    state["restart"]["last_message"] = (ans.peer_id, ans.id)
    save_state()