MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / SubStorePlugin

Class SubStorePlugin

sub/sub.ts:147–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145• <code>${mainPrefix}sub restore</code> - 恢复`;
146
147class SubStorePlugin extends Plugin {
148
149 description = `Sub-Store 管理\n\n${help}`;
150
151 cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = {
152 sub: async (msg) => {
153 const parts = msg.text?.split(/\s+/) || [];
154 const cmd = (parts[1] || "help").toLowerCase();
155 const arg = parts[2];
156
157 // // 检查是否在收藏夹
158 // if (!(await isSavedMessages(msg))) {
159 // await msg.edit({ text: "⚠️ 此插件仅限在「收藏夹」中使用" });
160 // return;
161 // }
162 if ((msg as any).isGroup || (msg as any).isChannel) {
163 await msg.edit({
164 text: "❌ 为保护用户隐私,禁止在公共对话环境使用",
165 parseMode: "html",
166 });
167 return;
168 }
169
170 // 检查root权限
171 if (
172 os.platform() !== "linux" ||
173 !process.getuid ||
174 process.getuid() !== 0
175 ) {
176 await msg.edit({ text: "❌ 需要Linux root权限" });
177 return;
178 }
179
180 try {
181 switch (cmd) {
182 case "help":
183 await msg.edit({ text: help, parseMode: "html" });
184 break;
185
186 case "up":
187 // 检查Docker完整性
188 await msg.edit({ text: "🔍 检查Docker完整性..." });
189 const dockerCheck = await checkDockerIntegrity();
190 if (!dockerCheck.valid) {
191 await msg.edit({
192 text: `❌ Docker检查失败: ${dockerCheck.error}\n\n🔧 请先执行: <code>${mainPrefix}sub fix-docker</code>`,
193 parseMode: "html",
194 });
195 return;
196 }
197
198 const secret = crypto.randomBytes(16).toString("hex");
199
200 // 分步骤部署,每步单独执行和检查
201 try {
202 await msg.edit({ text: "✅ Docker检查通过\n🛠 创建目录..." });
203 await sh("mkdir -p /root/sub-store /root/sub-store-data");
204

Callers

nothing calls this directly

Calls 7

checkDockerIntegrityFunction · 0.85
shFunction · 0.85
getSubStoreVersionFunction · 0.85
getRemoteVersionFunction · 0.85
compareVersionsFunction · 0.85
editMethod · 0.45
downloadMediaMethod · 0.45

Tested by

no test coverage detected