aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/bot_code.ts
blob: 688587eae8acb9f1e3aac27bdae86d1e45671154 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import defaultBotCode from "../assets/bot_template.txt?raw";

const BOT_CODE_KEY = "bot_code";

export function getBotCode(): string {
  let botCode = localStorage.getItem(BOT_CODE_KEY);
  if (!botCode) {
    botCode = defaultBotCode;
  }
  return botCode;
}

export function hasBotCode(): boolean {
  return !!localStorage.getItem(BOT_CODE_KEY);
}

export function saveBotCode(botCode: string) {
  localStorage.setItem(BOT_CODE_KEY, botCode);
}