(chatKey: string)
| 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(); |
no test coverage detected