From 719dd72fa354745e9924355b91a92efe5e8cbcc5 Mon Sep 17 00:00:00 2001 From: yzyyz1387 <1796031384@qq.com> Date: Sat, 30 Sep 2023 04:10:08 +0800 Subject: [PATCH] =?UTF-8?q?:memo:=20v0.1.10=20:bug:=20fix:=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=86=E4=B8=8B=E8=BD=BD=E5=8D=AB=E6=98=9F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84bug=20:sparkles:=20feat:=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=88=AA=E5=9B=BE=EF=BC=8C=E5=91=BD?= =?UTF-8?q?=E4=BB=A4`/s`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cqsat/path.py | 1 + cqsat/sat/sat_shoot_url_bank.py | 81 +++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 cqsat/sat/sat_shoot_url_bank.py diff --git a/cqsat/path.py b/cqsat/path.py index 617fff1..89b2409 100644 --- a/cqsat/path.py +++ b/cqsat/path.py @@ -32,6 +32,7 @@ CACHE_CSS = TLE_CACHE_PATH / 'css.cache' CACHE_OTHER = TLE_CACHE_PATH / 'other.cache' SHOOTS_OUT_PATH = LOCAL / 'shoots_out' +SHOOTS_URL_BANK = LOCAL / 'shoots_url_bank.json' MDC_GENERATOR_PATH = LOCAL / 'mdc_generator' diff --git a/cqsat/sat/sat_shoot_url_bank.py b/cqsat/sat/sat_shoot_url_bank.py new file mode 100644 index 0000000..5bbce13 --- /dev/null +++ b/cqsat/sat/sat_shoot_url_bank.py @@ -0,0 +1,81 @@ +# python3 +# -*- coding: utf-8 -*- +# @Time : 2023-09-30 1:01 +# @Author : yzyyz +# @Email : youzyyz1384@qq.com +# @File : sat_shoot_url_bank.py +# @Software: PyCharm +import json + +from ..utils import * +from ..path import * +from ..config import * + +if plugin_config.sat_proxy_url: + logger.info(plugin_config.sat_proxy_url) + +url_bank = [ + { + "url": "https://www.df2et.de/tevel/", + "cmd": ["t", "查询小火车", "小火车"], + "path": "tevel.png", + "locator": "html", + "time_out": 10 + }, + { + "url": "https://amsat.org/status/index.php", + "cmd": ["a", "amsat"], + "path": "amsat.png", + "locator": "xpath=/html/body/center[4]", + "time_out": 10 + + }, + { + "url": "https://www.github.com/yzyyz1387/cqsat", + "cmd": ["home", "cqsat"], + "path": "cqsat.png", + "locator": "html", + "time_out": 5, + "proxy": plugin_config.sat_proxy_url, + "timeout": 90000, + }, + { + "url": "https://sathunt.com/", + "cmd": ['css', 'cs'], + "path": "css.png", + "locator": "html", + "time_out": 0 + } + +] + + +class UrlBank: + def __init__(self): + if SHOOTS_URL_BANK.exists(): + self.url_bank = json_load(SHOOTS_URL_BANK) + else: + self.url_bank = url_bank + json_upload(SHOOTS_URL_BANK, self.url_bank) + + def get(self): + return json_load(SHOOTS_URL_BANK) if SHOOTS_URL_BANK.exists() else self.url_bank + + def add(self, **kwargs): + self.url_bank.append(kwargs) + json_upload(SHOOTS_URL_BANK, url_bank) + + def remove(self, **kwargs): + url = kwargs.get("url", None) + cmd = kwargs.get("cmd", None) + path = kwargs.get("path", None) + for item in self.url_bank: + if url in item["url"] or cmd in item["cmd"] or path in item["path"]: + self.url_bank.remove(item) + json_upload(SHOOTS_URL_BANK, self.url_bank) + return True + + @staticmethod + def default(): + json_upload(SHOOTS_URL_BANK, url_bank) + return True diff --git a/setup.py b/setup.py index d1352a3..0d8b4a3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="nonebot-plugin-cqsat", - version="0.1.9", + version="0.1.10", author="yzyyz1387", author_email="youzyyz1384@gmail.com", keywords=("ham", "nonebot2", "nonebot", "radio", "nonebot_plugin"),