Skip to content

Commit

Permalink
⬆ New version released with some updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Monarchdos committed Jul 15, 2024
1 parent 14f2d79 commit 85839a4
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 52 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<h1 align="center">_✨ 心灵鸡汤 ✨_</h1>
<p align="center">
<a href="https://v2.nonebot.dev/"><img src="https://v2.nonebot.dev/logo.png" width="200" height="200" alt="nonebot"></a>
</p>
<div align="center">
_✨ 心灵鸡汤 ✨_
<br><br><a href="./LICENSE">
<a href="./LICENSE">
<img src="https://img.shields.io/github/license/Monarchdos/nonebot_plugin_soup.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot_plugin_soup">
Expand All @@ -12,9 +9,7 @@ _✨ 心灵鸡汤 ✨_
<a href="https://www.python.org">
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
</a>


</div>
</p>

## 📖 介绍

Expand All @@ -39,6 +34,11 @@ pip install nonebot-plugin-soup
nonebot.load_plugin('nonebot_plugin_soup')
```

**升级插件**
```bash
pip install --upgrade nonebot-plugin-soup
```

## 🎉 使用

<table>
Expand All @@ -57,17 +57,34 @@ nonebot.load_plugin('nonebot_plugin_soup')

</table>

## 📃 配置项

直接在全局配置项`env.dev`后添加即可,配置项修改后重启NoneBot生效。

#### chickensoup_reply_at

类型:Bool

默认值:True

说明:是否开启机器人回复后艾特用户。

```
chickensoup_reply_at=true
```

## 📝 更新日志

<details>
<summary>展开/收起</summary>

## **2023-01-11 V1.0.0**
## **2024-07-15 V1.1.0**

* 优化代码结构.
* 新增机器人回复是否'@用户'的设置.

## **2023-01-11 V1.0.0**

* 插件发布~

</details>

41 changes: 27 additions & 14 deletions nonebot_plugin_soup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
'''
Name: Code.
Name: ChickenSoup
Author: Monarchdos
Date: 2023-01-11
Date: 2023-01-11 16:04:41
LastEditTime: 2024-07-15 15:51:41
'''
from nonebot import on_command
from nonebot.plugin import on_regex
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message, MessageSegment, GroupMessageEvent
from nonebot import on_command, logger, get_plugin_config
from nonebot.plugin import PluginMetadata
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message, MessageSegment, GroupMessageEvent
from .config import Config
import requests

__plugin_meta__ = PluginMetadata(
name = "心灵鸡汤",
description = "来一碗心灵鸡汤吧",
usage = "鸡汤,毒鸡汤",
type="application",
homepage="https://github.com/Monarchdos/nonebot_plugin_soup",
supported_adapters={"~onebot.v11"},
)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
url = "https://api.ayfre.com/"

plugin_config = get_plugin_config(Config)

jt = on_command('鸡汤', priority=1, block=True)
@jt.handle()
async def jt_(bot: Bot, event: GroupMessageEvent):
res = str(requests.get(url=url+"jt?type=bot", verify=False).text)
if "wwwroot" in res or "html" in res: res = "gg"
await jt.send(message=Message(res), at_sender=True)
try:
core = "68747470733a2f2f6170692e61796672652e636f6d2f6a743f747970653d626f74267665723d312e312e30"
res = ("\n" if plugin_config.chickensoup_reply_at else "") + str(requests.get(bytes.fromhex(core).decode()).text)
if "wwwroot" in res or "html" in res or len(res) == 1: return
await jt.send(message=Message(res), at_sender=plugin_config.chickensoup_reply_at)
except requests.RequestException as e:
logger.warning("Server connection failed.")

djt = on_command('毒鸡汤', priority=1, block=True)
@djt.handle()
async def djt_(bot: Bot, event: GroupMessageEvent):
res = str(requests.get(url=url+"djt?type=bot", verify=False).text)
if "wwwroot" in res or "html" in res: res = "gg"
await djt.send(message=Message(res), at_sender=True)
try:
core = "68747470733a2f2f6170692e61796672652e636f6d2f646a743f747970653d626f74267665723d312e312e30"
res = ("\n" if plugin_config.chickensoup_reply_at else "") + str(requests.get(bytes.fromhex(core).decode()).text)
if "wwwroot" in res or "html" in res or len(res) == 1: return
await djt.send(message=Message(res), at_sender=plugin_config.chickensoup_reply_at)
except requests.RequestException as e:
logger.warning("Server connection failed.")
16 changes: 16 additions & 0 deletions nonebot_plugin_soup/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'''
Name: ChickenSoup.Config
Author: Monarchdos
Date: 2024-07-15 15:14:38
LastEditTime: 2024-07-15 15:15:56
'''
from pydantic import BaseModel, validator

class Config(BaseModel):
chickensoup_reply_at: bool = True

@validator('chickensoup_reply_at', pre=True, always=True)
def check_boolean(cls, v):
if not isinstance(v, bool):
raise ValueError('chickensoup_reply_at must be a boolean value')
return v
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "nonebot-plugin-soup"
version = "1.1.0"
description = "来一碗心灵鸡汤吧♥"
authors = ["Monarchdos <admin@ayfre.com>"]
readme = "README.md"
homepage = "https://github.com/Monarchdos/nonebot_plugin_soup"
repository = "https://github.com/Monarchdos/nonebot_plugin_soup"
documentation = "https://github.com/Monarchdos/nonebot_plugin_soup#readme"
keywords = ["nonebot", "nonebot2", "ChickenSoup"]

[tool.poetry.dependencies]
python = "^3.8"
requests = "*"
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
nonebot-adapter-onebot = ">=2.0.0-beta.1,<3.0.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
28 changes: 0 additions & 28 deletions setup.py

This file was deleted.

0 comments on commit 85839a4

Please # to comment.