示例#1
0
from utils.decorators import SyncToAsync
from utils.manager import PluginManager
from utils.message import processSession

from .config import CONFIG
from .parse import BiliParser, IDCoverter, getVideoInfo

REPLY_FORMAT = CONFIG.customize.video
POWER_GROUP = SUPERUSER | GROUP_ADMIN
MATCH_AV = compileRegexp(CONFIG.customize.regexp.av)
MATCH_BV = compileRegexp(CONFIG.customize.regexp.bv)

__plugin_name__ = "bilibili"

PluginManager(__plugin_name__)


@on_command("bilibili_info", aliases=("视频信息", "b站视频"))
@processSession(pluginName=__plugin_name__)
@SyncToAsync
def vidInfo(session: CommandSession):
    aid = session.state["id"]
    responseData = getVideoInfo(aid)
    try:
        parsedData = BiliParser.parse(responseData)
    except Exception:
        if session.state.get("auto", False):
            return
        else:
            raise
示例#2
0
from re import compile as compileRegexp

from nonebot import CommandSession, on_command, scheduler
from nonebot.permission import GROUP_ADMIN, PRIVATE_FRIEND, SUPERUSER

from utils.decorators import SyncToAsync
from utils.exception import BotExistError
from utils.manager import PluginManager, nameJoin
from utils.message import processSession

from .config import CONFIG, __plugin_name__
from .network import RefreshFeed, downloadFeed
from .parse import rssParser

PluginManager(__plugin_name__, defaultSettings={"subscribed": {}})
SUBSCRIBE_COMMAND = nameJoin(__plugin_name__, "subscribe")
TEST_COMMAND = nameJoin(__plugin_name__, "test")

URL_MATCH_REGEX = compileRegexp(
    r"(https?|ftp)://((?:\w|\d|[-+&@#/%?=~_|!:,.;])+(?:\w|\d|[-+&@#/%=~_|]))")
REFRESH_FEED = RefreshFeed()
POWER_GROUP = GROUP_ADMIN | PRIVATE_FRIEND | SUPERUSER


@on_command(SUBSCRIBE_COMMAND,
            aliases=("rss订阅", "RSS订阅"),
            permission=POWER_GROUP)
@processSession
@SyncToAsync
def rssSubscribe(session: CommandSession):
    rssLink: str = session.get("link")