How vmoranv/astrbot_plugin_pixiv_search works
Project type and purpose
• This is an AstrBot plugin ("AstrBot Pixiv 搜索插件"). It is an _extension_ to the AstrBot chatbot framework. Its sole purpose is to parse Pixiv‑related commands from users, call the Pixiv API (via pixivpy3 and aiohttp), and return image results or metadata back through AstrBot into a chat platform.
File structure
• Top‑level files only:
• main.py – the plugin’s entry point (command definitions, API calls, response formatting)
• metadata.yaml – plugin metadata (name, version, hooks) used by AstrBot’s plugin manager
• _conf_schema.json – configuration schema for AstrBot’s WebUI (defines refresh_token, R18 mode, quantity, etc.)
• requirements.txt – external Python dependencies (pixivpy3, aiohttp)
• README.md, LICENSE – documentation
• No frontend, no database, no persistent storage.
• This is a single-process, plugin-based architecture where AstrBot loads and isolates each plugin.
README for additional insights
• The README outlines user‑facing commands (e.g. /pixiv, /pixiv_ranking, /pixiv_related), configuration options, setup steps.
• It notes that AstrBot handles plugin discovery, dependency installation, configuration UI, and command routing.
Main components & interactions
a. Components
• User (chat client: QQ/Telegram/WeChat)
• Chat Platform API (e.g., Telegram API)
• AstrBot Core
• Plugin Manager
• Configuration Store (WebUI + _conf_schema.json)
• Command Router
• Pixiv Plugin
• main.py (command handlers + business logic)
• metadata.yaml (registration)
• _conf_schema.json (configuration schema)
• Python runtime with dependencies (pixivpy3, aiohttp)
• External Pixiv API
• (Optional) HTTP Proxy (if configured)
b. Relationships & data flow
1. User sends /pixiv tag1,tag2 in chat
2. Chat Platform forwards message to AstrBot Core
3. AstrBot Core’s Command Router inspects metadata.yaml, dispatches to Pixiv Plugin
4. Plugin’s main.py reads user arguments + loads plugin-specific configuration (refresh_token, R18 mode) from AstrBot Configuration Store
5. Plugin makes HTTP calls to the Pixiv API (via pixivpy3 + aiohttp), optionally through a proxy
6. Pixiv API returns JSON data (illustration URLs, titles, tags)
7. Plugin formats results (images + caption) and returns to AstrBot Core
8. AstrBot sends formatted message/images back through Chat Platform API to the user
c. Architectural patterns & principles
• Plugin architecture: loosely‑coupled components loaded at runtime
• Configuration‑driven behavior: via _conf_schema.json and AstrBot’s WebUI
• Single responsibility: plugin only handles Pixiv commands; AstrBot handles messaging, plugin isolation, dependency management
d. Key technologies & libraries
• Python 3.10+
• AstrBot plugin framework (core)
• pixivpy3 (Pixiv API wrapper)
• aiohttp (async HTTP client)