MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / build_plug_list

Function build_plug_list

astrbot/cli/utils/plugin.py:135–214  ·  view source on GitHub ↗

Build plugin list containing local and online plugin information Args: plugins_dir (Path): Plugin directory path Returns: list: List of dicts containing plugin information

(plugins_dir: Path)

Source from the content-addressed store, hash-verified

133
134
135def build_plug_list(plugins_dir: Path) -> list:
136 """Build plugin list containing local and online plugin information
137
138 Args:
139 plugins_dir (Path): Plugin directory path
140
141 Returns:
142 list: List of dicts containing plugin information
143
144 """
145 # Get local plugin info
146 result = []
147 if plugins_dir.is_dir():
148 for plugin_dir in plugins_dir.iterdir():
149 if not plugin_dir.is_dir():
150 continue
151
152 # Load metadata from metadata.yaml
153 metadata = load_yaml_metadata(plugin_dir)
154
155 if "desc" not in metadata and "description" in metadata:
156 metadata["desc"] = metadata["description"]
157
158 # If metadata loaded successfully, add to result list
159 if metadata and all(
160 k in metadata for k in ["name", "desc", "version", "author", "repo"]
161 ):
162 result.append(
163 {
164 "name": str(metadata.get("name", "")),
165 "desc": str(metadata.get("desc", "")),
166 "version": str(metadata.get("version", "")),
167 "author": str(metadata.get("author", "")),
168 "repo": str(metadata.get("repo", "")),
169 "status": PluginStatus.INSTALLED,
170 "local_path": str(plugin_dir),
171 },
172 )
173
174 # Get online plugin list
175 online_plugins_dict = {}
176 try:
177 with httpx.Client() as client:
178 resp = client.get("https://api.soulter.top/astrbot/plugins")
179 resp.raise_for_status()
180 data = resp.json()
181 for plugin_id, plugin_info in data.items():
182 online_plugins_dict[str(plugin_id)] = {
183 "name": str(plugin_id),
184 "desc": str(plugin_info.get("desc", "")),
185 "version": str(plugin_info.get("version", "")),
186 "author": str(plugin_info.get("author", "")),
187 "repo": str(plugin_info.get("repo", "")),
188 "status": PluginStatus.NOT_INSTALLED,
189 "local_path": None,
190 }
191 except Exception as e:
192 click.echo(f"Failed to get online plugin list: {e}", err=True)

Calls 9

load_yaml_metadataFunction · 0.85
popMethod · 0.80
appendMethod · 0.45
getMethod · 0.45
raise_for_statusMethod · 0.45
jsonMethod · 0.45
itemsMethod · 0.45
compare_versionMethod · 0.45
valuesMethod · 0.45