mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 20:06:12 +08:00
add auto download chromium
This commit is contained in:
parent
ad6836680f
commit
b2ce29f6a9
@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
from html import escape
|
from html import escape
|
||||||
|
import os
|
||||||
from time import asctime
|
from time import asctime
|
||||||
from typing import Awaitable, Callable, Optional
|
from typing import Awaitable, Callable, Optional
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ from nonebot.adapters.cqhttp.message import MessageSegment
|
|||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from pyppeteer import connect, launch
|
from pyppeteer import connect, launch
|
||||||
from pyppeteer.browser import Browser
|
from pyppeteer.browser import Browser
|
||||||
|
from pyppeteer.chromium_downloader import check_chromium, download_chromium
|
||||||
from pyppeteer.page import Page
|
from pyppeteer.page import Page
|
||||||
|
|
||||||
from .plugin_config import plugin_config
|
from .plugin_config import plugin_config
|
||||||
@ -19,6 +21,10 @@ class Singleton(type):
|
|||||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||||
return cls._instances[cls]
|
return cls._instances[cls]
|
||||||
|
|
||||||
|
if not plugin_config.hk_reporter_browser and not plugin_config.hk_reporter_use_local \
|
||||||
|
and not check_chromium():
|
||||||
|
os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'
|
||||||
|
download_chromium()
|
||||||
|
|
||||||
class Render(metaclass=Singleton):
|
class Render(metaclass=Singleton):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user