加了一言插件
This commit is contained in:
parent
dd880b49fb
commit
37b4cfac9a
35
src/plugins/YiYanAPI/.gitignore
vendored
Normal file
35
src/plugins/YiYanAPI/.gitignore
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# Virtual Environment
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
2
src/plugins/YiYanAPI/README.md
Normal file
2
src/plugins/YiYanAPI/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# YiYanAPI
|
||||||
|
只要你发一言,就会给你一言
|
3
src/plugins/YiYanAPI/__init__.py
Normal file
3
src/plugins/YiYanAPI/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from .main import YiYanAPI
|
||||||
|
|
||||||
|
__all__ = ["YiYanAPI"]
|
28
src/plugins/YiYanAPI/main.py
Normal file
28
src/plugins/YiYanAPI/main.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import requests
|
||||||
|
from ncatbot.plugin import BasePlugin, CompatibleEnrollment
|
||||||
|
from ncatbot.core import GroupMessage, PrivateMessage, BaseMessage
|
||||||
|
|
||||||
|
bot = CompatibleEnrollment # 兼容回调函数注册器
|
||||||
|
|
||||||
|
|
||||||
|
class YiYanAPI(BasePlugin):
|
||||||
|
name = "YiYanAPI" # 插件名称
|
||||||
|
version = "0.0.1" # 插件版本
|
||||||
|
author = "pythagodzilla" # 插件作者
|
||||||
|
info = "每日一言" # 插件描述
|
||||||
|
|
||||||
|
@bot.private_event()
|
||||||
|
async def on_message(self, msg: PrivateMessage):
|
||||||
|
if msg.message[0]["type"] == "text":
|
||||||
|
if msg.raw_message == "一言":
|
||||||
|
content = requests.get("https://v1.hitokoto.cn/?c=f&encode=text").text
|
||||||
|
|
||||||
|
await self.api.post_private_msg(msg.user_id, content)
|
||||||
|
|
||||||
|
@bot.group_event()
|
||||||
|
async def on_message(self, msg: GroupMessage):
|
||||||
|
if msg.message[0]["type"] == "text":
|
||||||
|
if msg.raw_message == "一言":
|
||||||
|
content = requests.get("https://v1.hitokoto.cn/?c=f&encode=text").text
|
||||||
|
|
||||||
|
await self.api.post_group_msg(msg.group_id, content)
|
2
src/plugins/YiYanAPI/requirements.txt
Normal file
2
src/plugins/YiYanAPI/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 插件依赖项
|
||||||
|
# 例如: requests==2.28.1
|
Loading…
x
Reference in New Issue
Block a user