From d21305e5f427459a09dbfe0ef10da62b9685e6a7 Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Mon, 8 Feb 2021 00:25:14 +0800 Subject: [PATCH] use screen shot --- Dockerfile | 1 + poetry.lock | 413 ++++++++++--------- pyproject.toml | 1 + src/plugins/hk_reporter/config.py | 3 +- src/plugins/hk_reporter/config_manager.py | 3 +- src/plugins/hk_reporter/platform/bilibili.py | 3 +- src/plugins/hk_reporter/platform/rss.py | 3 +- src/plugins/hk_reporter/platform/weibo.py | 3 +- src/plugins/hk_reporter/plugin_config.py | 1 + src/plugins/hk_reporter/utils.py | 58 ++- 10 files changed, 288 insertions(+), 201 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7261373..3f7c3e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3.9 +RUN apt-get update && apt-get install chromium fonts-wqy-microhei RUN python3 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple RUN python3 -m pip install poetry && poetry config virtualenvs.create false WORKDIR /app diff --git a/poetry.lock b/poetry.lock index aa0321b..ca5ba79 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,16 @@ +[[package]] +name = "appdirs" +version = "1.4.4" +description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +category = "main" +optional = false +python-versions = "*" + +[package.source] +type = "legacy" +url = "https://mirrors.aliyun.com/pypi/simple" +reference = "aliyun" + [[package]] name = "appnope" version = "0.1.2" @@ -5,12 +18,11 @@ description = "Disable App Nap on macOS >= 10.9" category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\" and sys_platform == \"darwin\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "apscheduler" @@ -20,6 +32,11 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" +[package.dependencies] +pytz = "*" +six = ">=1.4.0" +tzlocal = ">=2.0,<3.0" + [package.extras] asyncio = ["trollius"] doc = ["sphinx", "sphinx-rtd-theme"] @@ -33,16 +50,10 @@ tornado = ["tornado (>=4.3)"] twisted = ["twisted"] zookeeper = ["kazoo"] -[package.dependencies] -pytz = "*" -setuptools = ">=0.7" -six = ">=1.4.0" -tzlocal = ">=2.0,<3.0" - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "arrow" @@ -56,9 +67,9 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" python-dateutil = ">=2.7.0" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "astroid" @@ -74,9 +85,9 @@ six = ">=1.12,<2.0" wrapt = ">=1.11,<2.0" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "beautifulsoup4" @@ -86,19 +97,17 @@ category = "main" optional = false python-versions = "*" +[package.dependencies] +soupsieve = {version = ">1.2", markers = "python_version >= \"3.0\""} + [package.extras] html5lib = ["html5lib"] lxml = ["lxml"] -[package.dependencies] -[package.dependencies.soupsieve] -version = ">1.2" -python = ">=3.0" - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "binaryornot" @@ -112,9 +121,9 @@ python-versions = "*" chardet = ">=3.0.2" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "bs4" @@ -128,9 +137,9 @@ python-versions = "*" beautifulsoup4 = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "certifi" @@ -141,9 +150,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "chardet" @@ -154,9 +163,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "click" @@ -167,9 +176,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "colorama" @@ -180,9 +189,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "cookiecutter" @@ -204,9 +213,9 @@ requests = ">=2.23.0" six = ">=1.10" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "decorator" @@ -215,12 +224,11 @@ description = "Decorators for Humans" category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*" -marker = "python_version >= \"3.4\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "fastapi" @@ -230,20 +238,20 @@ category = "main" optional = false python-versions = ">=3.6" -[package.extras] -all = ["requests (>=2.24.0,<3.0.0)", "aiofiles (>=0.5.0,<0.6.0)", "jinja2 (>=2.11.2,<3.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<2.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "graphene (>=2.1.8,<3.0.0)", "ujson (>=3.0.0,<4.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn (>=0.12.0,<0.14.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)"] -dev = ["python-jose (>=3.1.0,<4.0.0)", "passlib (>=1.7.2,<2.0.0)", "autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn (>=0.12.0,<0.14.0)", "graphene (>=2.1.8,<3.0.0)"] -doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=6.1.4,<7.0.0)", "markdown-include (>=0.5.1,<0.6.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.2.0)", "typer-cli (>=0.0.9,<0.0.10)", "pyyaml (>=5.3.1,<6.0.0)"] -test = ["pytest (5.4.3)", "pytest-cov (2.10.0)", "pytest-asyncio (>=0.14.0,<0.15.0)", "mypy (0.790)", "flake8 (>=3.8.3,<4.0.0)", "black (20.8b1)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.15.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "databases (>=0.3.2,<0.4.0)", "orjson (>=3.2.1,<4.0.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "aiofiles (>=0.5.0,<0.6.0)", "flask (>=1.1.2,<2.0.0)"] - [package.dependencies] pydantic = ">=1.0.0,<2.0.0" starlette = "0.13.6" +[package.extras] +all = ["requests (>=2.24.0,<3.0.0)", "aiofiles (>=0.5.0,<0.6.0)", "jinja2 (>=2.11.2,<3.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<2.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "graphene (>=2.1.8,<3.0.0)", "ujson (>=3.0.0,<4.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)"] +dev = ["python-jose[cryptography] (>=3.1.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "graphene (>=2.1.8,<3.0.0)"] +doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=6.1.4,<7.0.0)", "markdown-include (>=0.5.1,<0.6.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.2.0)", "typer-cli (>=0.0.9,<0.0.10)", "pyyaml (>=5.3.1,<6.0.0)"] +test = ["pytest (==5.4.3)", "pytest-cov (==2.10.0)", "pytest-asyncio (>=0.14.0,<0.15.0)", "mypy (==0.790)", "flake8 (>=3.8.3,<4.0.0)", "black (==20.8b1)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.15.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.4.0)", "orjson (>=3.2.1,<4.0.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "aiofiles (>=0.5.0,<0.6.0)", "flask (>=1.1.2,<2.0.0)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "feedparser" @@ -257,9 +265,9 @@ python-versions = ">=3.6" sgmllib3k = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "h11" @@ -270,9 +278,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "httpcore" @@ -282,17 +290,17 @@ category = "main" optional = false python-versions = ">=3.6" -[package.extras] -http2 = ["h2 (>=3,<5)"] - [package.dependencies] h11 = "<1.0.0" sniffio = ">=1.0.0,<2.0.0" +[package.extras] +http2 = ["h2 (>=3,<5)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "httptools" @@ -301,15 +309,14 @@ description = "A collection of framework independent HTTP protocol utils." category = "main" optional = false python-versions = "*" -marker = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\"" [package.extras] -test = ["Cython (0.29.14)"] +test = ["Cython (==0.29.14)"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "httpx" @@ -319,23 +326,20 @@ category = "main" optional = false python-versions = ">=3.6" +[package.dependencies] +certifi = "*" +httpcore = ">=0.12.0,<0.13.0" +rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]} +sniffio = "*" + [package.extras] brotli = ["brotlipy (>=0.7.0,<0.8.0)"] http2 = ["h2 (>=3.0.0,<4.0.0)"] -[package.dependencies] -certifi = "*" -httpcore = ">=0.12.0,<0.13.0" -sniffio = "*" - -[package.dependencies.rfc3986] -version = ">=1.3,<2" -extras = ["idna2008"] - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "idna" @@ -346,9 +350,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "ipdb" @@ -359,16 +363,12 @@ optional = false python-versions = ">=2.7" [package.dependencies] -setuptools = "*" - -[package.dependencies.ipython] -version = ">=5.1.0" -python = ">=3.4" +ipython = {version = ">=5.1.0", markers = "python_version >= \"3.4\""} [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "ipython" @@ -377,7 +377,18 @@ description = "IPython: Productive Interactive Computing" category = "dev" optional = false python-versions = ">=3.3" -marker = "python_version >= \"3.4\"" + +[package.dependencies] +appnope = {version = "*", markers = "sys_platform == \"darwin\""} +colorama = {version = "*", markers = "sys_platform == \"win32\""} +decorator = "*" +jedi = ">=0.10" +pexpect = {version = "*", markers = "sys_platform != \"win32\""} +pickleshare = "*" +prompt-toolkit = ">=1.0.4,<2.0.0" +pygments = "*" +simplegeneric = ">0.8" +traitlets = ">=4.2" [package.extras] all = ["qtconsole", "ipyparallel", "ipykernel", "Sphinx (>=1.3)", "requests", "testpath", "nbformat", "nbconvert", "notebook", "pygments", "ipywidgets", "nose (>=0.10.1)"] @@ -390,23 +401,10 @@ parallel = ["ipyparallel"] qtconsole = ["qtconsole"] test = ["nose (>=0.10.1)", "requests", "testpath", "pygments", "nbformat", "ipykernel", "numpy"] -[package.dependencies] -appnope = "*" -colorama = "*" -decorator = "*" -jedi = ">=0.10" -pexpect = "*" -pickleshare = "*" -prompt-toolkit = ">=1.0.4,<2.0.0" -pygments = "*" -setuptools = ">=18.5" -simplegeneric = ">0.8" -traitlets = ">=4.2" - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "ipython-genutils" @@ -415,12 +413,11 @@ description = "Vestigial utilities from IPython" category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "isort" @@ -436,9 +433,9 @@ requirements_deprecated_finder = ["pip-api", "pipreqs"] pipfile_deprecated_finder = ["pipreqs", "requirementslib"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "jedi" @@ -448,17 +445,17 @@ category = "dev" optional = false python-versions = ">=3.6" -[package.extras] -qa = ["flake8 (3.8.3)", "mypy (0.782)"] -testing = ["Django (<3.1)", "colorama", "docopt", "pytest (<6.0.0)"] - [package.dependencies] parso = ">=0.8.0,<0.9.0" +[package.extras] +qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] +testing = ["Django (<3.1)", "colorama", "docopt", "pytest (<6.0.0)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "jinja2" @@ -468,16 +465,16 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -[package.extras] -i18n = ["Babel (>=0.8)"] - [package.dependencies] MarkupSafe = ">=0.23" +[package.extras] +i18n = ["Babel (>=0.8)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "jinja2-time" @@ -492,9 +489,9 @@ arrow = "*" jinja2 = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "lazy-object-proxy" @@ -505,9 +502,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "loguru" @@ -517,17 +514,17 @@ category = "main" optional = false python-versions = ">=3.5" +[package.dependencies] +colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} +win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} + [package.extras] dev = ["codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "tox (>=3.9.0)", "tox-travis (>=0.12)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "Sphinx (>=2.2.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "black (>=19.10b0)", "isort (>=5.1.1)"] -[package.dependencies] -colorama = ">=0.3.4" -win32-setctime = ">=1.0.0" - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "markupsafe" @@ -538,9 +535,9 @@ optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "mccabe" @@ -551,9 +548,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "nb-cli" @@ -563,10 +560,6 @@ category = "dev" optional = false python-versions = ">=3.7,<4.0" -[package.extras] -deploy = ["docker-compose (>=1.27.2,<2.0.0)"] -docker = ["docker-compose (>=1.27.2,<2.0.0)"] - [package.dependencies] click = ">=7.1.2,<8.0.0" colorama = ">=0.4.3,<0.5.0" @@ -575,10 +568,14 @@ nonebot2 = ">=2.0.0-alpha.7,<3.0.0" pyfiglet = ">=0.8.post1,<0.9" pyinquirer = "1.0.3" +[package.extras] +deploy = ["docker-compose (>=1.27.2,<2.0.0)"] +docker = ["docker-compose (>=1.27.2,<2.0.0)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "nonebot-plugin-apscheduler" @@ -593,9 +590,9 @@ apscheduler = ">=3.7.0,<4.0.0" nonebot2 = ">=2.0.0-alpha.8,<3.0.0" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "nonebot2" @@ -609,18 +606,15 @@ python-versions = ">=3.7,<4.0" fastapi = ">=0.63.0,<0.64.0" httpx = ">=0.16.1,<0.17.0" loguru = ">=0.5.1,<0.6.0" +pydantic = {version = ">=1.7.3,<2.0.0", extras = ["dotenv", "typing_extensions"]} pygtrie = ">=2.4.1,<3.0.0" uvicorn = ">=0.11.5,<0.12.0" websockets = ">=8.1,<9.0" -[package.dependencies.pydantic] -version = ">=1.7.3,<2.0.0" -extras = ["typing_extensions", "dotenv"] - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "parso" @@ -631,13 +625,13 @@ optional = false python-versions = ">=3.6" [package.extras] -qa = ["flake8 (3.8.3)", "mypy (0.782)"] +qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] testing = ["docopt", "pytest (<6.0.0)"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pexpect" @@ -646,15 +640,14 @@ description = "Pexpect allows easy control of interactive console applications." category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\" and sys_platform != \"win32\"" [package.dependencies] ptyprocess = ">=0.5" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pickleshare" @@ -663,12 +656,11 @@ description = "Tiny 'shelve'-like database with concurrency support" category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "poyo" @@ -679,9 +671,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "prompt-toolkit" @@ -696,9 +688,9 @@ six = ">=1.9.0" wcwidth = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "ptyprocess" @@ -707,12 +699,11 @@ description = "Run a subprocess in a pseudo terminal" category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\" and sys_platform != \"win32\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pydantic" @@ -722,24 +713,32 @@ category = "main" optional = false python-versions = ">=3.6" +[package.dependencies] +python-dotenv = {version = ">=0.10.4", optional = true, markers = "extra == \"dotenv\""} +typing-extensions = {version = ">=3.7.2", optional = true, markers = "extra == \"typing_extensions\""} + [package.extras] dotenv = ["python-dotenv (>=0.10.4)"] email = ["email-validator (>=1.0.3)"] typing_extensions = ["typing-extensions (>=3.7.2)"] -[package.dependencies] -[package.dependencies.python-dotenv] -version = ">=0.10.4" -optional = true - -[package.dependencies.typing-extensions] -version = ">=3.7.2" -optional = true - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" + +[[package]] +name = "pyee" +version = "8.1.0" +description = "A port of node.js's EventEmitter to python." +category = "main" +optional = false +python-versions = "*" + +[package.source] type = "legacy" +url = "https://mirrors.aliyun.com/pypi/simple" +reference = "aliyun" [[package]] name = "pyfiglet" @@ -750,9 +749,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pygments" @@ -763,9 +762,9 @@ optional = false python-versions = ">=3.5" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pygtrie" @@ -776,9 +775,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pyinquirer" @@ -794,9 +793,9 @@ Pygments = ">=2.2.0" regex = ">=2016.11.21" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pylint" @@ -808,15 +807,35 @@ python-versions = ">=3.5.*" [package.dependencies] astroid = ">=2.4.0,<=2.5" -colorama = "*" +colorama = {version = "*", markers = "sys_platform == \"win32\""} isort = ">=4.2.5,<6" mccabe = ">=0.6,<0.7" toml = ">=0.7.1" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" + +[[package]] +name = "pyppeteer" +version = "0.2.5" +description = "Headless chrome/chromium automation library (unofficial port of puppeteer)" +category = "main" +optional = false +python-versions = ">=3.6.1,<4.0.0" + +[package.dependencies] +appdirs = ">=1.4.3,<2.0.0" +pyee = ">=8.1.0,<9.0.0" +tqdm = ">=4.42.1,<5.0.0" +urllib3 = ">=1.25.8,<2.0.0" +websockets = ">=8.1,<9.0" + +[package.source] type = "legacy" +url = "https://mirrors.aliyun.com/pypi/simple" +reference = "aliyun" [[package]] name = "python-dateutil" @@ -830,9 +849,9 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" six = ">=1.5" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "python-dotenv" @@ -846,9 +865,9 @@ python-versions = "*" cli = ["click (>=5.0)"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "python-slugify" @@ -858,16 +877,16 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -[package.extras] -unidecode = ["Unidecode (>=1.1.1)"] - [package.dependencies] text-unidecode = ">=1.3" +[package.extras] +unidecode = ["Unidecode (>=1.1.1)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "pytz" @@ -878,9 +897,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "regex" @@ -891,9 +910,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "requests" @@ -903,20 +922,20 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -[package.extras] -security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] -socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"] - [package.dependencies] certifi = ">=2017.4.17" chardet = ">=3.0.2,<5" idna = ">=2.5,<3" urllib3 = ">=1.21.1,<1.27" +[package.extras] +security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] +socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "rfc3986" @@ -926,18 +945,16 @@ category = "main" optional = false python-versions = "*" +[package.dependencies] +idna = {version = "*", optional = true, markers = "extra == \"idna2008\""} + [package.extras] idna2008 = ["idna"] -[package.dependencies] -[package.dependencies.idna] -version = "*" -optional = true - [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "sgmllib3k" @@ -948,9 +965,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "simplegeneric" @@ -959,12 +976,11 @@ description = "Simple generic functions (similar to Python's own len(), pickle.d category = "dev" optional = false python-versions = "*" -marker = "python_version >= \"3.4\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "six" @@ -975,9 +991,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "sniffio" @@ -988,9 +1004,9 @@ optional = false python-versions = ">=3.5" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "soupsieve" @@ -999,12 +1015,11 @@ description = "A modern CSS selector implementation for Beautiful Soup." category = "main" optional = false python-versions = ">=3.5" -marker = "python_version >= \"3.0\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "starlette" @@ -1018,9 +1033,9 @@ python-versions = ">=3.6" full = ["aiofiles", "graphene", "itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "ujson"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "text-unidecode" @@ -1031,9 +1046,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "tinydb" @@ -1044,9 +1059,9 @@ optional = false python-versions = ">=3.5,<4.0" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "toml" @@ -1057,9 +1072,26 @@ optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" + +[[package]] +name = "tqdm" +version = "4.56.0" +description = "Fast, Extensible Progress Meter" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" + +[package.extras] +dev = ["py-make (>=0.1.0)", "twine", "wheel"] +telegram = ["requests"] + +[package.source] type = "legacy" +url = "https://mirrors.aliyun.com/pypi/simple" +reference = "aliyun" [[package]] name = "traitlets" @@ -1068,18 +1100,17 @@ description = "Traitlets Python configuration system" category = "dev" optional = false python-versions = ">=3.7" -marker = "python_version >= \"3.4\"" - -[package.extras] -test = ["pytest"] [package.dependencies] ipython-genutils = "*" +[package.extras] +test = ["pytest"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "typing-extensions" @@ -1090,9 +1121,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "tzlocal" @@ -1106,27 +1137,27 @@ python-versions = "*" pytz = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "urllib3" version = "1.26.3" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" [package.extras] brotli = ["brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] -socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] +socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "uvicorn" @@ -1136,20 +1167,20 @@ category = "main" optional = false python-versions = "*" -[package.extras] -watchgodreload = ["watchgod (>=0.6,<0.7)"] - [package.dependencies] click = ">=7.0.0,<8.0.0" h11 = ">=0.8,<0.10" -httptools = ">=0.1.0,<0.2.0" -uvloop = ">=0.14.0" +httptools = {version = ">=0.1.0,<0.2.0", markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\""} +uvloop = {version = ">=0.14.0", markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\""} websockets = ">=8.0.0,<9.0.0" +[package.extras] +watchgodreload = ["watchgod (>=0.6,<0.7)"] + [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "uvloop" @@ -1158,12 +1189,11 @@ description = "Fast implementation of asyncio event loop on top of libuv" category = "main" optional = false python-versions = "*" -marker = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\"" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "wcwidth" @@ -1174,9 +1204,9 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "websockets" @@ -1187,9 +1217,9 @@ optional = false python-versions = ">=3.6.1" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "win32-setctime" @@ -1198,15 +1228,14 @@ description = "A small Python utility to set file creation time on Windows" category = "main" optional = false python-versions = ">=3.5" -marker = "sys_platform == \"win32\"" [package.extras] dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"] [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [[package]] name = "wrapt" @@ -1217,16 +1246,20 @@ optional = false python-versions = "*" [package.source] +type = "legacy" url = "https://mirrors.aliyun.com/pypi/simple" reference = "aliyun" -type = "legacy" [metadata] -lock-version = "1.0" +lock-version = "1.1" python-versions = "^3.9" -content-hash = "e0bc808855b72fa2e9b868ab4aff4d9e938924536a98d0a345cb21917a43496e" +content-hash = "02d96d899638d0a8f2ecb5fa430b8fa03c5303ef503d3f906fe9cebfafba64f2" [metadata.files] +appdirs = [ + {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, + {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, +] appnope = [ {file = "appnope-0.1.2-py2.py3-none-any.whl", hash = "sha256:93aa393e9d6c54c5cd570ccadd8edad61ea0c4b9ea7a01409020c9aa019eb442"}, {file = "appnope-0.1.2.tar.gz", hash = "sha256:dd83cd4b5b460958838f6eb3000c660b1f9caf2a5b1de4264e941512f603258a"}, @@ -1471,6 +1504,10 @@ pydantic = [ {file = "pydantic-1.7.3-py3-none-any.whl", hash = "sha256:38be427ea01a78206bcaf9a56f835784afcba9e5b88fbdce33bbbfbcd7841229"}, {file = "pydantic-1.7.3.tar.gz", hash = "sha256:213125b7e9e64713d16d988d10997dabc6a1f73f3991e1ff8e35ebb1409c7dc9"}, ] +pyee = [ + {file = "pyee-8.1.0-py2.py3-none-any.whl", hash = "sha256:383973b63ad7ed5e3c0311f8b179c52981f9e7b3eaea0e9a830d13ec34dde65f"}, + {file = "pyee-8.1.0.tar.gz", hash = "sha256:92dacc5bd2bdb8f95aa8dd2585d47ca1c4840e2adb95ccf90034d64f725bfd31"}, +] pyfiglet = [ {file = "pyfiglet-0.8.post1-py2.py3-none-any.whl", hash = "sha256:d555bcea17fbeaf70eaefa48bb119352487e629c9b56f30f383e2c62dd67a01c"}, {file = "pyfiglet-0.8.post1.tar.gz", hash = "sha256:c6c2321755d09267b438ec7b936825a4910fec696292139e664ca8670e103639"}, @@ -1489,6 +1526,10 @@ pylint = [ {file = "pylint-2.6.0-py3-none-any.whl", hash = "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f"}, {file = "pylint-2.6.0.tar.gz", hash = "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210"}, ] +pyppeteer = [ + {file = "pyppeteer-0.2.5-py3-none-any.whl", hash = "sha256:d4cb4a5ef94b00c1073aed888b39646ce26cff3339cff7a3f1f1cc307bf50408"}, + {file = "pyppeteer-0.2.5.tar.gz", hash = "sha256:c2974be1afa13b17f7ecd120d265d8b8cd324d536a231c3953ca872b68aba4af"}, +] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, {file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"}, @@ -1589,6 +1630,10 @@ toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] +tqdm = [ + {file = "tqdm-4.56.0-py2.py3-none-any.whl", hash = "sha256:4621f6823bab46a9cc33d48105753ccbea671b68bab2c50a9f0be23d4065cb5a"}, + {file = "tqdm-4.56.0.tar.gz", hash = "sha256:fe3d08dd00a526850568d542ff9de9bbc2a09a791da3c334f3213d8d0bbbca65"}, +] traitlets = [ {file = "traitlets-5.0.5-py3-none-any.whl", hash = "sha256:69ff3f9d5351f31a7ad80443c2674b7099df13cc41fc5fa6e2f6d3b0330b0426"}, {file = "traitlets-5.0.5.tar.gz", hash = "sha256:178f4ce988f69189f7e523337a3e11d91c786ded9360174a3d9ca83e79bc5396"}, diff --git a/pyproject.toml b/pyproject.toml index 6b9d7a9..b1d6104 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ bs4 = "^0.0.1" tinydb = "^4.3.0" nonebot_plugin_apscheduler = "^0.1.2" feedparser = "^6.0.2" +pyppeteer = "^0.2.5" [tool.poetry.dev-dependencies] pylint = "^2.6.0" diff --git a/src/plugins/hk_reporter/config.py b/src/plugins/hk_reporter/config.py index c52df17..a935e1b 100644 --- a/src/plugins/hk_reporter/config.py +++ b/src/plugins/hk_reporter/config.py @@ -23,8 +23,7 @@ class NoSuchUserException(Exception): class NoSuchSubscribeException(Exception): pass -@Singleton -class Config(): +class Config(metaclass=Singleton): migrate_version = 1 diff --git a/src/plugins/hk_reporter/config_manager.py b/src/plugins/hk_reporter/config_manager.py index 2d96314..f3f6cf8 100644 --- a/src/plugins/hk_reporter/config_manager.py +++ b/src/plugins/hk_reporter/config_manager.py @@ -7,6 +7,7 @@ from nonebot import on_command from .platform.utils import check_sub_target from .config import Config, NoSuchSubscribeException +from .utils import parse_text async def check_is_owner_or_admin(bot: Bot, event: Event): return await (GROUP_ADMIN | GROUP_OWNER)(bot, event) @@ -36,7 +37,7 @@ async def _(bot: Bot, event: Event, state: T_State): res = '订阅的帐号为:\n' for sub in sub_list: res += '{} {} {}\n'.format(sub['target_type'], sub['target_name'], sub['target']) - await query_sub.finish(res) + await query_sub.finish(await parse_text(res)) del_sub = on_command("删除订阅", rule=to_me(), priority=5) @del_sub.handle() diff --git a/src/plugins/hk_reporter/platform/bilibili.py b/src/plugins/hk_reporter/platform/bilibili.py index 5006a78..9e1f419 100644 --- a/src/plugins/hk_reporter/platform/bilibili.py +++ b/src/plugins/hk_reporter/platform/bilibili.py @@ -6,8 +6,7 @@ import httpx import json import time -@Singleton -class Bilibili: +class Bilibili(metaclass=Singleton): def __init__(self): self.exists_posts = defaultdict(set) diff --git a/src/plugins/hk_reporter/platform/rss.py b/src/plugins/hk_reporter/platform/rss.py index ac11666..97b347e 100644 --- a/src/plugins/hk_reporter/platform/rss.py +++ b/src/plugins/hk_reporter/platform/rss.py @@ -18,8 +18,7 @@ async def get_rss_info(url) -> str: feed = feedparser.parse(data) return feed.feed.title -@Singleton -class Rss: +class Rss(metaclass=Singleton): def __init__(self): self.exists_posts = defaultdict(set) diff --git a/src/plugins/hk_reporter/platform/weibo.py b/src/plugins/hk_reporter/platform/weibo.py index df729c7..762a3e2 100644 --- a/src/plugins/hk_reporter/platform/weibo.py +++ b/src/plugins/hk_reporter/platform/weibo.py @@ -9,8 +9,7 @@ from nonebot import logger from ..utils import Singleton from ..post import Post -@Singleton -class Weibo: +class Weibo(metaclass=Singleton): def __init__(self): self.exists_posts = defaultdict(set) diff --git a/src/plugins/hk_reporter/plugin_config.py b/src/plugins/hk_reporter/plugin_config.py index 48e55e9..2d05a60 100644 --- a/src/plugins/hk_reporter/plugin_config.py +++ b/src/plugins/hk_reporter/plugin_config.py @@ -3,6 +3,7 @@ from pydantic import BaseSettings class PlugConfig(BaseSettings): hk_reporter_config_path: str = "" + use_pic: bool = False class Config: extra = 'ignore' diff --git a/src/plugins/hk_reporter/utils.py b/src/plugins/hk_reporter/utils.py index 9e3e156..7e0571d 100644 --- a/src/plugins/hk_reporter/utils.py +++ b/src/plugins/hk_reporter/utils.py @@ -1,12 +1,54 @@ -class Singleton(object): +import nonebot +from pyppeteer import launch +from html import escape +from hashlib import sha256 - def __init__(self, cls): - self._cls = cls - self._instance = {} - def __call__(self): - if self._cls not in self._instance: - self._instance[self._cls] = self._cls() - return self._instance[self._cls] +from . import plugin_config + +class Singleton(type): + _instances = {} + def __call__(cls, *args, **kwargs): + if cls not in cls._instances: + cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) + return cls._instances[cls] supported_target_type = ('weibo', 'bilibili', 'rss') +class Render(metaclass=Singleton): + + def __init__(self): + self.page = None + + async def init(self): + browser = await launch(execublePath='/usr/bin/chromium') + self.page = await browser.newPage() + + async def text_to_pic(self, text: str) -> str: + hash_text = sha256(text.encode()).hexdigest()[:20] + lines = text.split('\n') + parsed_lines = list(map(lambda x: '

{}

'.format(escape(x)), lines)) + html_text = '
{}
'.format(''.join(parsed_lines)) + with open('/tmp/text-{}.html'.format(hash_text), 'w') as f: + f.write(html_text) + await self.page.goto('file:///tmp/text-{}.html'.format(hash_text)) + div = await self.page.querySelector('div') + path = '/tmp/img-{}.png'.format(hash_text) + await div.screenshot(path=path) + return path + + async def text_to_pic_cqcode(self, text:str) -> str: + path = await self.text_to_pic(text) + return '[CQ:image,file=file://{}]'.format(path) + +async def _start(): + r = Render() + await r.init() + +nonebot.get_driver().on_startup(_start) +async def parse_text(text: str): + if plugin_config.use_pic: + r = Render() + return await r.text_to_pic_cqcode(text) + else: + return text +