-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆ New version released with some updates.
- Loading branch information
1 parent
14f2d79
commit 85839a4
Showing
5 changed files
with
90 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |