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

Method ensureMainChat

deepwiki/deepwiki.ts:217–233  ·  view source on GitHub ↗
(chatKey: string)

Source from the content-addressed store, hash-verified

215 }
216
217 private async ensureMainChat(chatKey: string): Promise<MainChatState> {
218 this.ensureReady();
219 const key = this.gk(chatKey);
220
221 await this.dbMain.read();
222 this.dbMain.data ||= { chats: {}, telegraphToken: "" };
223 this.dbMain.data.chats ||= {};
224 this.dbMain.data.telegraphToken ||= "";
225
226 if (!this.dbMain.data.chats[key]) {
227 this.dbMain.data.chats[key] = this.normalizeMainState({ currentTag: "", repos: {} });
228 await this.dbMain.write();
229 } else {
230 this.dbMain.data.chats[key] = this.normalizeMainState(this.dbMain.data.chats[key]);
231 }
232 return this.dbMain.data.chats[key];
233 }
234
235 private async ensureCtxChat(chatKey: string): Promise<CtxChatState> {
236 this.ensureReady();

Callers 4

getChatStateMethod · 0.95
setRepoMethod · 0.95
deleteRepoMethod · 0.95
setCurrentMethod · 0.95

Calls 4

ensureReadyMethod · 0.95
gkMethod · 0.95
normalizeMainStateMethod · 0.95
writeMethod · 0.80

Tested by

no test coverage detected