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

Class GitManagerPlugin

git_PR/git_PR.ts:137–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135class GitManagerPlugin extends Plugin {
136 description: string = `通过Git API管理PR\n\n${help_text}`;
137
138 cmdHandlers = {
139 [pluginName]: async (msg: Api.Message) => {
140 const lines = msg.text?.trim()?.split(/\r?\n/g) || [];
141 const parts = lines?.[0]?.trim()?.split(/\s+/g) || [];
142 const [, ...args] = parts;
143 const sub = (args[0] || "").toLowerCase();
144
145 try {
146 // 无参数:显示帮助
147 if (!sub) {
148 await sendLongMessage(msg, help_text);
149 return;
150 }
151
152 // help 在前:.git help [sub]
153 if (sub === "help" || sub === "h") {
154 await sendLongMessage(msg, help_text);
155 return;
156 }
157
158 // help 在后:.git [sub] help
159 if (args[1] && (args[1].toLowerCase() === "help" || args[1].toLowerCase() === "h")) {
160 await sendLongMessage(msg, help_text);
161 return;
162 }
163
164 switch (sub) {
165 case "login":
166 await this.handleLogin(msg, args.slice(1));
167 break;
168 case "repos":
169 await this.handleRepos(msg);
170 break;
171 case "prs":
172 await this.handlePRs(msg, args.slice(1));
173 break;
174 case "merge":
175 await this.handleMerge(msg, args.slice(1));
176 break;
177 case "mergeall":
178 await this.handleMergeAll(msg, args.slice(1));
179 break;
180 default:
181 await msg.edit({ text: `❌ <b>未知子命令:</b> <code>${htmlEscape(sub)}</code>\n\n${help_text}`, parseMode: "html" });
182 }
183 } catch (error: any) {
184 console.error('[git] 插件执行失败:', error);
185 await msg.edit({ text: `❌ <b>操作失败:</b> ${htmlEscape(error.message)}`, parseMode: "html" });
186 }
187 },
188 };
189
190 private async handleLogin(msg: Api.Message, args: string[]) {
191 if (args.length < 3) {
192 await msg.edit({ text: `❌ <b>参数不足</b>\n\n<b>格式:</b> <code>${mainPrefix}${pluginName} login &lt;邮箱&gt; &lt;用户名&gt; &lt;Token&gt;</code>`, parseMode: "html" });
193 return;
194 }

Callers

nothing calls this directly

Calls 9

handleLoginMethod · 0.95
handleReposMethod · 0.95
handlePRsMethod · 0.95
handleMergeMethod · 0.95
handleMergeAllMethod · 0.95
errorMethod · 0.80
sendLongMessageFunction · 0.70
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected