()
| 3 | |
| 4 | // Function to load user and group data from JSON file |
| 5 | function loadUserGroupData() { |
| 6 | try { |
| 7 | const dataPath = path.join(__dirname, '../data/userGroupData.json'); |
| 8 | if (!fs.existsSync(dataPath)) { |
| 9 | // Create the file with default structure if it doesn't exist |
| 10 | const defaultData = { |
| 11 | antibadword: {}, |
| 12 | antilink: {}, |
| 13 | welcome: {}, |
| 14 | goodbye: {}, |
| 15 | chatbot: {}, |
| 16 | warnings: {}, |
| 17 | sudo: [] |
| 18 | }; |
| 19 | fs.writeFileSync(dataPath, JSON.stringify(defaultData, null, 2)); |
| 20 | return defaultData; |
| 21 | } |
| 22 | const data = JSON.parse(fs.readFileSync(dataPath, 'utf8')); |
| 23 | return data; |
| 24 | } catch (error) { |
| 25 | console.error('Error loading user group data:', error); |
| 26 | return { |
| 27 | antibadword: {}, |
| 28 | antilink: {}, |
| 29 | welcome: {}, |
| 30 | goodbye: {}, |
| 31 | chatbot: {}, |
| 32 | warnings: {} |
| 33 | }; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // Function to save user and group data to JSON file |
| 38 | function saveUserGroupData(data) { |
no outgoing calls
no test coverage detected