Skip to content

Commit

Permalink
第一次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwen-4 committed Oct 19, 2024
0 parents commit 216b846
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish

on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
162 changes: 162 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# 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/
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/
cover/

# 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/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .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

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm-project.org/#use-with-ide
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__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/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<div align="center">
<a href="https://v2.nonebot.dev/store"><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
<br>
<p><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
</div>

<div align="center">

# nonebot-plugin-picsetu

_✨ 基于NoneBot的涩图插件 ✨_


</div>

## 📖 介绍

一个涩图插件,就是你们想的那样

## 💿 安装

<details open>
<summary>使用 nb-cli 安装</summary>
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

nb plugin install nonebot-plugin-picsetu

</details>

<details>
<summary>使用包管理器安装</summary>
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令

<details>
<summary>pip</summary>

pip install nonebot-plugin-picsetu
</details>
<details>
<summary>pdm</summary>

pdm add nonebot-plugin-picsetu
</details>
<details>
<summary>poetry</summary>

poetry add nonebot-plugin-picsetu
</details>
<details>
<summary>conda</summary>

conda install nonebot-plugin-picsetu
</details>

打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入

plugins = ["nonebot_plugin_picsetu"]

</details>

## 🎉 使用
### 指令表
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|:-----:|:----:|:----:|:----:|:----:|
| setu | 所有人 || 通用 | 别忘了加前缀啊 |
62 changes: 62 additions & 0 deletions nonebot_plugin_picsetu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from nonebot import on_command
from nonebot.adapters.onebot.v11 import MessageSegment
from nonebot.plugin import PluginMetadata

import httpx, random
setu_cmd = on_command("setu", aliases={"色图", "涩图"})


__plugin_meta__ = PluginMetadata(
name="涩图插件",
description="随机获取一张涩图",
type="application",
homepage="https://github.com/zhongwen-4/nonebot-plugin-picsetu",
supported_adapters={"~onebot.v11"}
)


@setu_cmd.handle()
async def setu_handle():
a_randint = random.randint(1, 100)
if a_randint < 20:
await setu_cmd.send("稍等,图片正在赶来的路上")

async with httpx.AsyncClient() as client:
res = await client.get(
"https://api.lolicon.app/setu/v2"
)
url = await client.get(res.json()["data"][0]["urls"]["original"])

if url.status_code == 200:
await setu_cmd.finish(MessageSegment.image(res.json()["data"][0]["urls"]["original"]))
else:
await setu_cmd.finish("出错了,请重试")


if a_randint < 70 and a_randint > 20:
await setu_cmd.send("稍等,图片正在赶来的路上")

async with httpx.AsyncClient() as client:
res = await client.get(
"https://image.anosu.top/pixiv/json"
)
url = await client.get(res.json()[0]["url"])

if url.status_code == 200:
await setu_cmd.finish(MessageSegment.image(res.json()[0]["url"]))
else:
await setu_cmd.finish("出错了,请重试")


if a_randint > 70:
await setu_cmd.send("稍等,图片正在赶来的路上")
async with httpx.AsyncClient() as client:
res = await client.get(
"https://misaliu.top/api/randomfurry/?format=json"
)

url = await client.get(res.json()[0]["url"])
if url.status_code == 200:
await setu_cmd.finish(MessageSegment.image(res.json()[0]["url"]))
else:
await setu_cmd.finish("出错了,请重试")
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
name = "nonebot_plugin_picsetu"
version = "0.0.1"
description = "Default template for PDM package"
authors = [
{name = "zhongwen-4", email = "[email protected]"},
]
dependencies = [
"nonebot2>=2.3.3",
"nonebot-adapter-onebot>=2.4.5",
"httpx>=0.27.2",
]
requires-python = ">= 3.10"
readme = "README.md"
license = {text = "MIT"}


[tool.pdm]
distribution = false

0 comments on commit 216b846

Please sign in to comment.