Skip to content

Commit

Permalink
fix bot name issue
Browse files Browse the repository at this point in the history
  • Loading branch information
NAKAMURA Masayuki committed Mar 22, 2022
1 parent e5be8d3 commit 755a5b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/backend/bot-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ export class BotArchive {

const otherFiles = []

// ベースファイルが既存ボットではなくテンプレートの場合は、bot.config.jsonを新たに生成
if (!overwriteExistingBot) {
// ベースファイルが既存ボットではなくテンプレートの場合は、bot.config.jsonを新たに生成
otherFiles.push({
name: 'bot.config.json',
content: JSON.stringify(botConfig)
})
} else {
// ベースファイルが既存ボットの場合は、ボットの名前の末尾の「 (botId)」を削除
// ※上書きインポートするたびにボット名が伸びていく問題の対策
const botConfigFC = noConflictFiles.find(file => file.name === 'bot.config.json')
const botConfigContent = JSON.parse(botConfigFC.content.toString())
botConfigContent.name = botConfigContent.name.replace(/ \([^()]+\)$/, '')
botConfigFC.content = JSON.stringify(botConfigContent)
}

const allFiles = [...noConflictFiles, ...mergedFiles, ...newFiles, ...otherFiles]
Expand Down

0 comments on commit 755a5b8

Please sign in to comment.