Compare commits
22
Commits
68486ee39c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f0c700d9f | ||
|
|
aaa1ee91ae | ||
|
|
faf6b39e45 | ||
|
|
0a938100a8 | ||
|
|
37b4cfac9a | ||
|
|
dd880b49fb | ||
|
|
aa824d3257 | ||
|
|
63b97d2d2f | ||
|
|
2dc3faaf03 | ||
|
|
1da7bc067d | ||
|
|
cf14fc22c2 | ||
|
|
a30c3699a1 | ||
|
|
29a96bb1ff | ||
|
|
89aa8f2bf7 | ||
|
|
758fe4b1f0 | ||
|
|
65fa057ab4 | ||
|
|
d456805d46 | ||
|
|
a3c5ae75d3 | ||
|
|
fe244d95b4 | ||
|
|
58b5dcff73 | ||
|
|
06266378e1 | ||
|
|
504a472b22 |
+5
-1
@@ -1 +1,5 @@
|
|||||||
tests
|
tests
|
||||||
|
.env
|
||||||
|
src/data
|
||||||
|
src/logs
|
||||||
|
src/config.yaml
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "src/plugins/Weather"]
|
||||||
|
path = src/plugins/Weather
|
||||||
|
url = https://github.com/pythagodzi11a/Weather.git
|
||||||
|
[submodule "src/plugins/YiYanAPI"]
|
||||||
|
path = src/plugins/YiYanAPI
|
||||||
|
url = https://github.com/pythagodzi11a/YiYanAPI
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
3.13
|
||||||
+13
-7
@@ -3,17 +3,23 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
由于一上来就采用了远程开发的模式,所以在bot连接的过程中,需要在 ```bot.run()``` 函数中另外传入参数
|
由于一上来就采用了远程开发的模式,所以在bot连接的过程中,需要在 ```bot.run()``` 函数中另外传入参数
|
||||||
|
|
||||||
```python
|
```python
|
||||||
bot.run(
|
bot.run(
|
||||||
bt_uin = "bot account",
|
bt_uin="bot account",
|
||||||
root = "bot's master account",
|
root="bot's master account",
|
||||||
ws_uri = "ws://",
|
ws_uri="ws://",
|
||||||
ws_token = "Your token",
|
ws_token="Your token",
|
||||||
webui_uri = "http://Your server:port",
|
webui_uri="http://Your server:port",
|
||||||
webui_token = "Your token"
|
webui_token="Your token"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
具体的信息在 [配置项文档](https://docs.ncatbot.xyz/guide/kfcvme50/#%E9%85%8D%E7%BD%AE%E9%A1%B9%E5%88%97%E8%A1%A8) 中提及。
|
具体的信息在 [配置项文档](https://docs.ncatbot.xyz/guide/kfcvme50/#%E9%85%8D%E7%BD%AE%E9%A1%B9%E5%88%97%E8%A1%A8) 中提及。
|
||||||
一些报错是由于webui的token所导致的,默认值为napcat,另外连接都需要带上协议,例如连接webui时需要带上 ```http://```
|
一些报错是由于webui的token所导致的,默认值为napcat,另外连接都需要带上协议,例如连接webui时需要带上 ```http://```
|
||||||
---
|
---
|
||||||
|
|
||||||
|
官方文档已经给出了解析消息的示例,但是我仍然使用了raw_message来手动解析消息。我觉得这个锅要甩***1/3***给文档,
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
requests~=2.32.4
|
||||||
|
ncatbot~=3.8.8.post7
|
||||||
|
dotenv~=0.9.9
|
||||||
|
python-dotenv~=1.1.1
|
||||||
|
sqlmodel~=0.0.24
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
BOT_ACCOUNT="Your-bot-account"
|
||||||
|
ROOT_ACCOUNT="Your-root-account"
|
||||||
|
WS_URI="ws://Your-uri:port"
|
||||||
|
WS_TOKEN="Your-token"
|
||||||
|
WEBUI_URI="http://Your-uri:port"
|
||||||
|
WEBUI_TOKEN="Your-token
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import time
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from ncatbot.core import BotClient, GroupMessage, PrivateMessage
|
||||||
|
from ncatbot.utils import get_log
|
||||||
|
|
||||||
|
load_dotenv(dotenv_path=r".env")
|
||||||
|
|
||||||
|
bot = BotClient()
|
||||||
|
_log = get_log()
|
||||||
|
|
||||||
|
|
||||||
|
@bot.group_event()
|
||||||
|
async def on_receive_group_message(msg: GroupMessage):
|
||||||
|
_log.info(f"The message's meta data is: {str(msg)}")
|
||||||
|
_log.info(f"The message's raw message is: {msg.raw_message}")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.private_event()
|
||||||
|
async def on_receive_private_event(msg: PrivateMessage):
|
||||||
|
_log.info(f"The message's meta data is: {str(msg)}")
|
||||||
|
_log.info(f"The message's raw message is: {msg.raw_message}")
|
||||||
|
|
||||||
|
|
||||||
|
bot.run(
|
||||||
|
bt_uin=os.getenv("BOT_ACCOUNT"),
|
||||||
|
root=os.getenv("ROOT_ACCOUNT"),
|
||||||
|
ws_uri=os.getenv("WS_URI"),
|
||||||
|
ws_token=os.getenv("WS_TOKEN"),
|
||||||
|
webui_uri=os.getenv("WEBUI_URI"),
|
||||||
|
webui_token=os.getenv("WEBUI_TOKEN")
|
||||||
|
)
|
||||||
-92
@@ -1,92 +0,0 @@
|
|||||||
from ncatbot.core import BotClient, GroupMessage, PrivateMessage
|
|
||||||
# from ncatbot.core import (MessageChain, Text, Image)
|
|
||||||
from ncatbot.utils import get_log
|
|
||||||
import requests
|
|
||||||
|
|
||||||
bot = BotClient()
|
|
||||||
_log = get_log()
|
|
||||||
|
|
||||||
@bot.private_event()
|
|
||||||
async def on_receive_images_private_event(msg: PrivateMessage):
|
|
||||||
_log.info(msg)
|
|
||||||
|
|
||||||
if "url=https://" not in msg.raw_message:
|
|
||||||
return
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
file_name = msg.raw_message.split(",")[1].split("=")[1]
|
|
||||||
image_url = await bot.api.get_image(file_name)
|
|
||||||
real_url = image_url['data']['url']
|
|
||||||
except IndexError as e:
|
|
||||||
_log.debug(e)
|
|
||||||
real_url = "None"
|
|
||||||
file_name = "None"
|
|
||||||
except TypeError as e:
|
|
||||||
_log.debug(e)
|
|
||||||
real_url = "None"
|
|
||||||
file_name = "None"
|
|
||||||
|
|
||||||
if real_url == "None":
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
response = requests.get(real_url)
|
|
||||||
img = response.content
|
|
||||||
with open(f"data/pics/{file_name}", 'wb') as f:
|
|
||||||
f.write(img)
|
|
||||||
|
|
||||||
# file_name = msg.raw_message.split(",")[1].split("=")[1]
|
|
||||||
# image_url = await bot.api.get_image(file_name)
|
|
||||||
# real_url = image_url['data']['url']
|
|
||||||
#
|
|
||||||
# _log.debug(f"image's real url: {real_url}")
|
|
||||||
#
|
|
||||||
# try:
|
|
||||||
# response = requests.get(real_url)
|
|
||||||
# img = response.content
|
|
||||||
# with open(f"data/pics/{file_name}", 'wb') as f:
|
|
||||||
# f.write(img)
|
|
||||||
# except Exception as e:
|
|
||||||
# _log.error(e)
|
|
||||||
# pass
|
|
||||||
|
|
||||||
@bot.group_event()
|
|
||||||
async def on_receive_images_group_event(msg: GroupMessage):
|
|
||||||
_log.info(msg)
|
|
||||||
|
|
||||||
if "url=https://" not in msg.raw_message:
|
|
||||||
return
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
file_name = msg.raw_message.split(",")[1].split("=")[1]
|
|
||||||
image_url = await bot.api.get_image(file_name)
|
|
||||||
real_url = image_url['data']['url']
|
|
||||||
except IndexError as e:
|
|
||||||
_log.debug(e)
|
|
||||||
real_url = "None"
|
|
||||||
file_name = "None"
|
|
||||||
except TypeError as e:
|
|
||||||
_log.debug(e)
|
|
||||||
real_url = "None"
|
|
||||||
file_name = "None"
|
|
||||||
|
|
||||||
|
|
||||||
if real_url == "None":
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
response = requests.get(real_url)
|
|
||||||
img = response.content
|
|
||||||
with open(f"data/pics/{file_name}", 'wb') as f:
|
|
||||||
f.write(img)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
api = bot.run(
|
|
||||||
bt_uin="203758258",
|
|
||||||
root="1670671958",
|
|
||||||
ws_uri="ws://192.168.10.78:3001",
|
|
||||||
ws_token="",
|
|
||||||
webui_uri="http://192.168.10.78:6099",
|
|
||||||
webui_token="@Jtbx2mtblj"
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# DataBase
|
||||||
|
> 用于开发功能而做的插件。只是为了便于重载和测试。
|
||||||
|
|
||||||
|
用于和数据库进行交互。
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .dataBase import DataBase
|
||||||
|
|
||||||
|
__all__ = ['DataBase']
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
|||||||
|
from sqlmodel import SQLModel, Session, select, create_engine
|
||||||
|
from ncatbot.plugin import BasePlugin, CompatibleEnrollment
|
||||||
|
from ncatbot.utils import get_log
|
||||||
|
|
||||||
|
bot = CompatibleEnrollment()
|
||||||
|
_log = get_log()
|
||||||
|
|
||||||
|
|
||||||
|
class Data(SQLModel, table=True):
|
||||||
|
__tablename__ = 'file'
|
||||||
|
|
||||||
|
class DataBase(BasePlugin):
|
||||||
|
name = "DataBase"
|
||||||
|
version = "0.0.1"
|
||||||
|
author = "pythagodzilla"
|
||||||
|
info = "A plugin to control data base."
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ncatbot~=3.8.8.post7
|
||||||
|
dotenv~=0.9.9
|
||||||
|
python-dotenv~=1.1.1
|
||||||
|
sqlmodel~=0.0.24
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# GetFile
|
||||||
|
> 用于开发功能而做的插件。只是为了便于重载和测试。
|
||||||
|
|
||||||
|
用来保存所有的照片和视频的插件。
|
||||||
|
|
||||||
|
> **特殊说明**: 这个插件编写的时间略早,所以消息解析使用了一个极为不成熟的方法。不推荐再做更改。
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .get_file import GetFile
|
||||||
|
|
||||||
|
__all__ = ['GetFile']
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,102 @@
|
|||||||
|
from ncatbot.core import BotClient, GroupMessage, PrivateMessage
|
||||||
|
from ncatbot.utils import get_log
|
||||||
|
from ncatbot.plugin import BasePlugin, CompatibleEnrollment
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
# bot = BotClient()
|
||||||
|
bot = CompatibleEnrollment
|
||||||
|
_log = get_log()
|
||||||
|
|
||||||
|
|
||||||
|
class GetFile(BasePlugin):
|
||||||
|
name = "GetFile"
|
||||||
|
version = "0.0.1"
|
||||||
|
author = "pythagodzilla"
|
||||||
|
info = "A plugin to get images and videos"
|
||||||
|
|
||||||
|
async def on_load(self):
|
||||||
|
_log.info(f"Plugin {self.name} loaded! ")
|
||||||
|
|
||||||
|
@bot.private_event()
|
||||||
|
async def on_receive_images_private_event(self, msg: PrivateMessage):
|
||||||
|
if msg.message[0]["type"] == "image":
|
||||||
|
file_name = msg.message[0]["data"]["file"]
|
||||||
|
_log.info(f"Name of the image is: {file_name}")
|
||||||
|
|
||||||
|
image_url = await self.api.get_image(file_name)
|
||||||
|
_log.info(f"Image's information collected by \"get_image\" is: {image_url}")
|
||||||
|
real_url = image_url['data']['url']
|
||||||
|
_log.info(f"Image's real url is: {real_url}")
|
||||||
|
|
||||||
|
response = requests.get(real_url)
|
||||||
|
img = response.content
|
||||||
|
with open(f"../data/pics/{file_name}", 'wb') as f:
|
||||||
|
f.write(img)
|
||||||
|
|
||||||
|
@bot.group_event()
|
||||||
|
async def on_receive_images_group_event(self, msg: GroupMessage):
|
||||||
|
if msg.message[0]["type"] == "image":
|
||||||
|
file_name = msg.message[0]["data"]["file"]
|
||||||
|
_log.info(f"Name of the image is: {file_name}")
|
||||||
|
|
||||||
|
image_url = await self.api.get_image(file_name)
|
||||||
|
_log.info(f"Image's information collected by \"get_image\" is: {image_url}")
|
||||||
|
real_url = image_url['data']['url']
|
||||||
|
_log.info(f"Image's real url is: {real_url}")
|
||||||
|
|
||||||
|
response = requests.get(real_url)
|
||||||
|
img = response.content
|
||||||
|
with open(f"../data/pics/{file_name}", 'wb') as f:
|
||||||
|
f.write(img)
|
||||||
|
|
||||||
|
@bot.group_event()
|
||||||
|
async def on_receive_videos_group_event(self, msg: GroupMessage):
|
||||||
|
if msg.message[0]["type"] == "video":
|
||||||
|
file_name = msg.message[0]["data"]["file"]
|
||||||
|
_log.info(f"Name of the video is: {file_name}")
|
||||||
|
|
||||||
|
video_url = await self.api.get_file(file_name)
|
||||||
|
_log.info(f"Video's information collected by \"get_video\" is: {video_url}")
|
||||||
|
real_url = video_url['data']['url']
|
||||||
|
_log.info(f"Video's real url is: {real_url}")
|
||||||
|
|
||||||
|
response = requests.get(real_url)
|
||||||
|
video = response.content
|
||||||
|
with open(f"../data/videos/{file_name}", 'wb') as f:
|
||||||
|
f.write(video)
|
||||||
|
|
||||||
|
@bot.private_event()
|
||||||
|
async def on_receive_videos_private_event(self, msg: PrivateMessage):
|
||||||
|
if msg.message[0]["type"] == "video":
|
||||||
|
file_name = msg.message[0]["data"]["file"]
|
||||||
|
_log.info(f"Name of the video is: {file_name}")
|
||||||
|
|
||||||
|
video_url = await self.api.get_file(file_name)
|
||||||
|
_log.info(f"Video's information collected by \"get_video\" is: {video_url}")
|
||||||
|
real_url = video_url['data']['url']
|
||||||
|
_log.info(f"Video's real url is: {real_url}")
|
||||||
|
|
||||||
|
response = requests.get(real_url)
|
||||||
|
video = response.content
|
||||||
|
with open(f"../data/videos/{file_name}", 'wb') as f:
|
||||||
|
f.write(video)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
当单独运行这个程序时,会连接napcat并保存图片和视频到本地。
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
load_dotenv(dotenv_path=r"../../../.env")
|
||||||
|
bot = BotClient()
|
||||||
|
api = bot.run(
|
||||||
|
bt_uin=os.getenv("BOT_ACCOUNT"),
|
||||||
|
root=os.getenv("ROOT_ACCOUNT"),
|
||||||
|
ws_uri=os.getenv("WS_URI"),
|
||||||
|
ws_token=os.getenv("WS_TOKEN"),
|
||||||
|
webui_uri=os.getenv("WEBUI_URI"),
|
||||||
|
webui_token=os.getenv("WEBUI_TOKEN")
|
||||||
|
)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ncatbot~=3.8.8.post7
|
||||||
|
dotenv~=0.9.9
|
||||||
|
python-dotenv~=1.1.1
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Memigo 插件
|
||||||
|
|
||||||
|
## 简介
|
||||||
|
|
||||||
|
这是一个 NcatBot 插件模板。
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
- 群消息事件处理
|
||||||
|
- 好友消息事件处理
|
||||||
|
- 测试功能 (/test)
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
1. 在群聊中发送 "测试" 消息
|
||||||
|
2. 在私聊中发送 "测试" 消息
|
||||||
|
3. 使用 `/test` 命令测试功能
|
||||||
|
|
||||||
|
## 配置项
|
||||||
|
|
||||||
|
- `greeting`: 问候语,默认值为 "你好",可选值: ["你好", "Hello", "Hi"]
|
||||||
|
|
||||||
|
## 依赖
|
||||||
|
|
||||||
|
- NcatBot
|
||||||
|
|
||||||
|
## 作者
|
||||||
|
|
||||||
|
Your Name
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
MIT
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .main import Memigo
|
||||||
|
|
||||||
|
__all__ = ["Memigo"]
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from sqlmodel import Field, SQLModel, create_engine
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
load_dotenv("../../.env")
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectDatabase(SQLModel, table=True):
|
||||||
|
__tablename__ = 'BasicInformation'
|
||||||
|
|
||||||
|
id: int | None = Field(primary_key=True)
|
||||||
|
fileName: str | None
|
||||||
|
includedText: str | None
|
||||||
|
imageContent: str | None
|
||||||
|
memeKind: str | None
|
||||||
|
|
||||||
|
database_path = Path(os.getenv("DATA_PATH")) / "DataBase" / "data.db"
|
||||||
|
# if not database_path.exists():
|
||||||
|
# engine = create_engine(f"sqlite:///{database_path}")
|
||||||
|
#
|
||||||
|
# else:
|
||||||
|
# engine = create_engine(f"sqlite:///{database_path}")
|
||||||
|
# SQLModel.metadata.create_all(engine)
|
||||||
|
|
||||||
|
engine = create_engine(f"sqlite:///{database_path}")
|
||||||
|
SQLModel.metadata.create_all(engine)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from ncatbot.plugin import BasePlugin, CompatibleEnrollment
|
||||||
|
from ncatbot.core import GroupMessage, PrivateMessage, BaseMessage
|
||||||
|
from ncatbot.utils import get_log
|
||||||
|
|
||||||
|
bot = CompatibleEnrollment # 兼容回调函数注册器
|
||||||
|
_log = get_log()
|
||||||
|
|
||||||
|
class Memigo(BasePlugin):
|
||||||
|
name = "Memigo" # 插件名称
|
||||||
|
version = "0.0.1" # 插件版本
|
||||||
|
author = "pythagodzilla" # 插件作者
|
||||||
|
info = "你的meme分类好伙伴" # 插件描述
|
||||||
|
|
||||||
|
@bot.startup_event()
|
||||||
|
async def startup(self):
|
||||||
|
_log.info("Plugin Memigo has started up! ")
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# 插件依赖项
|
||||||
|
# 例如: requests==2.28.1
|
||||||
|
|
||||||
|
ncatbot~=3.8.8.post7
|
||||||
|
sqlmodel~=0.0.24
|
||||||
|
dotenv~=0.9.9
|
||||||
|
python-dotenv~=1.1.1
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Test 插件
|
||||||
|
|
||||||
|
## 简介
|
||||||
|
|
||||||
|
这是一个 NcatBot 插件模板。
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
- 群消息事件处理
|
||||||
|
- 好友消息事件处理
|
||||||
|
- 测试功能 (/test)
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
1. 在群聊中发送 "测试" 消息
|
||||||
|
2. 在私聊中发送 "测试" 消息
|
||||||
|
3. 使用 `/test` 命令测试功能
|
||||||
|
|
||||||
|
## 配置项
|
||||||
|
|
||||||
|
- `greeting`: 问候语,默认值为 "你好",可选值: ["你好", "Hello", "Hi"]
|
||||||
|
|
||||||
|
## 依赖
|
||||||
|
|
||||||
|
- NcatBot
|
||||||
|
|
||||||
|
## 作者
|
||||||
|
|
||||||
|
Your Name
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
MIT
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .main import Test
|
||||||
|
|
||||||
|
__all__ = ["Test"]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from ncatbot.core import PrivateMessage
|
||||||
|
from ncatbot.plugin import BasePlugin, CompatibleEnrollment
|
||||||
|
from ncatbot.utils import get_log
|
||||||
|
|
||||||
|
bot = CompatibleEnrollment # 兼容回调函数注册器
|
||||||
|
_log = get_log()
|
||||||
|
|
||||||
|
class Test(BasePlugin):
|
||||||
|
name = "Test" # 插件名称
|
||||||
|
version = "0.0.1" # 插件版本
|
||||||
|
author = "Your Name" # 插件作者
|
||||||
|
info = "这是一个示例插件,用于演示插件系统的基本功能" # 插件描述
|
||||||
|
dependencies = {} # 插件依赖,格式: {"插件名": "版本要求"}
|
||||||
|
|
||||||
|
# @bot.private_event()
|
||||||
|
# async def test_unzip(self, msg: PrivateMessage):
|
||||||
|
# _log.info(f"{msg.message[0]["type"]}")
|
||||||
|
|
||||||
|
@bot.private_event()
|
||||||
|
async def on_receive_images_private_event(self, msg: PrivateMessage):
|
||||||
|
if msg.message[0]["type"] == "image":
|
||||||
|
file_name = msg.message[0]["data"]["file"]
|
||||||
|
_log.warning(f"{file_name}")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# 插件依赖项
|
||||||
|
# 例如: requests==2.28.1
|
||||||
Submodule
+1
Submodule src/plugins/Weather added at 6d2b885b7b
Submodule
+1
Submodule src/plugins/YiYanAPI added at 88e4f85afd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user