Add functional code
This commit is contained in:
parent
23bc6c10f5
commit
f34b4f2cb3
5 changed files with 251 additions and 0 deletions
21
src/database.ts
Normal file
21
src/database.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { MSG_ID_FILE, DB_NAME } from "./config";
|
||||
import * as fs from "fs";
|
||||
|
||||
export const LOAD_MSG_ID = (): string => {
|
||||
return fs.readFileSync(`./${MSG_ID_FILE}`, `utf8`)
|
||||
};
|
||||
|
||||
|
||||
export const WRITE_MSG_ID = (new_id: string) => {
|
||||
return fs.writeFileSync(`./${MSG_ID_FILE}`, new_id)
|
||||
};
|
||||
|
||||
|
||||
export const LOAD_USED_QUOTES = (): string[] => {
|
||||
return JSON.parse(fs.readFileSync(`./${DB_NAME}`, `utf`));
|
||||
};
|
||||
|
||||
|
||||
export const WRITE_USED_QUOTES = (data: string[]) => {
|
||||
fs.writeFileSync(`${DB_NAME}`, JSON.stringify(data));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue