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"),