Init: Add fetch radar map on Nanjing
This commit is contained in:
141
.gitignore
vendored
Normal file
141
.gitignore
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/python
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
pytestdebug.log
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
doc/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/python
|
||||
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# radar-bot
|
||||
|
||||
## How to start
|
||||
|
||||
1. generate project using `nb create` .
|
||||
2. create your plugin using `nb plugin create` .
|
||||
3. writing your plugins under `src/plugins` folder.
|
||||
4. run your bot using `nb run --reload` .
|
||||
|
||||
## Documentation
|
||||
|
||||
See [Docs](https://nonebot.dev/)
|
||||
14
pyproject.toml
Normal file
14
pyproject.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[project]
|
||||
name = "radar-bot"
|
||||
version = "0.1.0"
|
||||
description = "radar-bot"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9, <4.0"
|
||||
|
||||
[tool.nonebot]
|
||||
adapters = [
|
||||
{ name = "OneBot V12", module_name = "nonebot.adapters.onebot.v12" }
|
||||
]
|
||||
plugins = []
|
||||
plugin_dirs = ["src/plugins"]
|
||||
builtin_plugins = ["echo"]
|
||||
53
src/plugins/rdnj.py
Normal file
53
src/plugins/rdnj.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from nonebot.params import EventMessage
|
||||
from nonebot.plugin import on_command
|
||||
from nonebot.rule import to_me
|
||||
|
||||
from nonebot.adapters.onebot.v11 import Bot,MessageEvent, GroupMessageEvent
|
||||
from nonebot.adapters.onebot.v11.message import Message, MessageSegment
|
||||
|
||||
import datetime, requests, time, pytz
|
||||
|
||||
rdnj = on_command("rdnj", rule=to_me())
|
||||
|
||||
@rdnj.handle()
|
||||
async def _(
|
||||
bot: Bot,
|
||||
evt: GroupMessageEvent,
|
||||
evt_msg: EventMessage()
|
||||
):
|
||||
|
||||
tz_utc = pytz.timezone('Etc/GMT')
|
||||
now_utc = datetime.datetime.now(tz_utc)
|
||||
aligned_min = (now_utc.minute // 6) * 6
|
||||
utc_time = now_utc.replace(
|
||||
minute=aligned_min,
|
||||
second=0,
|
||||
microsecond=0
|
||||
)
|
||||
|
||||
url = (
|
||||
f"https://image.nmc.cn/product/"
|
||||
f"{utc_time:%Y}/{utc_time:%m}/{utc_time:%d}/RDCP/"
|
||||
f"SEVP_AOC_RDCP_SLDAS3_ECREF_AZ9250_L88_PI_"
|
||||
f"{utc_time:%Y%m%d%H%M}00000.PNG"
|
||||
)
|
||||
|
||||
while True:
|
||||
try:
|
||||
reponse = requests.get(url,allow_redirects=True)
|
||||
if reponse.status_code==200:
|
||||
break
|
||||
else:
|
||||
utc_time -= datetime.timedelta(minutes=6)
|
||||
url = (
|
||||
f"https://image.nmc.cn/product/"
|
||||
f"{utc_time:%Y}/{utc_time:%m}/{utc_time:%d}/RDCP/"
|
||||
f"SEVP_AOC_RDCP_SLDAS3_ECREF_AZ9250_L88_PI_"
|
||||
f"{utc_time:%Y%m%d%H%M}00000.PNG"
|
||||
)
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error Fetching Image: {e}")
|
||||
|
||||
msg = MessageSegment(f"{url}\n") + MessageSegment.image(reponse.content)
|
||||
await rdnj.finish(msg)
|
||||
Reference in New Issue
Block a user