This commit is contained in:
Pyhtagodzilla 2025-08-03 15:42:50 +08:00
parent 37b4cfac9a
commit 0a938100a8
16 changed files with 220 additions and 27 deletions

View File

@ -1,27 +0,0 @@
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
def confirm_database_exists():
database_path = Path(os.getenv("DATABASE_PATH")) / "DataBase" / "data.db"
if not database_path.exists():
engine = create_engine(f"sqlite:///{database_path}")
SQLModel.metadata.create_all(engine)
if __name__ == "connect_database":
confirm_database_exists()

35
src/plugins/Memigo/.gitignore vendored Normal file
View 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

View File

@ -0,0 +1,33 @@
# Memigo 插件
## 简介
这是一个 NcatBot 插件模板。
## 功能
- 群消息事件处理
- 好友消息事件处理
- 测试功能 (/test)
## 使用方法
1. 在群聊中发送 "测试" 消息
2. 在私聊中发送 "测试" 消息
3. 使用 `/test` 命令测试功能
## 配置项
- `greeting`: 问候语,默认值为 "你好",可选值: ["你好", "Hello", "Hi"]
## 依赖
- NcatBot
## 作者
Your Name
## 许可证
MIT

View File

@ -0,0 +1,3 @@
from .main import Memigo
__all__ = ["Memigo"]

View File

@ -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)

View File

@ -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! ")

View File

@ -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

35
src/plugins/Test/.gitignore vendored Normal file
View 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

View File

@ -0,0 +1,33 @@
# Test 插件
## 简介
这是一个 NcatBot 插件模板。
## 功能
- 群消息事件处理
- 好友消息事件处理
- 测试功能 (/test)
## 使用方法
1. 在群聊中发送 "测试" 消息
2. 在私聊中发送 "测试" 消息
3. 使用 `/test` 命令测试功能
## 配置项
- `greeting`: 问候语,默认值为 "你好",可选值: ["你好", "Hello", "Hi"]
## 依赖
- NcatBot
## 作者
Your Name
## 许可证
MIT

View File

@ -0,0 +1,3 @@
from .main import Test
__all__ = ["Test"]

23
src/plugins/Test/main.py Normal file
View File

@ -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}")

View File

@ -0,0 +1,2 @@
# 插件依赖项
# 例如: requests==2.28.1