|
1 | | -const { readFile } = require('fs/promises'); |
2 | | -const path = require('node:path'); |
| 1 | +const { loadConfigVar, loadChnlMap } = require('./../backend/loadvar.js'); |
3 | 2 |
|
4 | 3 | // Full Hackmud-to-Discord color mapping // = U+001B |
5 | 4 | const hackmudToDiscordColors = { |
@@ -143,29 +142,12 @@ function fiveMinutesAgoToRubyTS() { |
143 | 142 | return Math.floor(fiveMinutesAgo / 1000); |
144 | 143 | } |
145 | 144 |
|
146 | | -async function loadChannelMappings() { |
147 | | - const mapRaw = await readFile(path.resolve(__dirname, '../channelMappings.json'), 'utf8'); |
148 | | - return JSON.parse(mapRaw); |
149 | | -} |
150 | | - |
151 | | -async function loadPullUsers() { |
152 | | - const configRaw = await readFile(path.resolve(__dirname, '../config.json'), 'utf8'); |
153 | | - const config = JSON.parse(configRaw); |
154 | | - return config.pullusers || []; |
155 | | -} |
156 | | - |
157 | | -async function loadMudToken() { |
158 | | - const configRaw = await readFile(path.resolve(__dirname, '../config.json'), 'utf8'); |
159 | | - const config = JSON.parse(configRaw); |
160 | | - return config.mudtoken || []; |
161 | | -} |
162 | | - |
163 | 145 | let lastTimestamp = fiveMinutesAgoToRubyTS(); |
164 | 146 |
|
165 | 147 | async function fetchNewMessages(client) { |
166 | | - const channelMappings = await loadChannelMappings(); |
167 | | - const pullusers = await loadPullUsers(); |
168 | | - const mudtoken = await loadMudToken(); |
| 148 | + const channelMappings = await loadChnlMap |
| 149 | + const pullusers = await loadConfigVar("pullusers"); |
| 150 | + const mudtoken = await loadConfigVar("mudtoken") |
169 | 151 | const apiUrl = 'https://www.hackmud.com/mobile/chats.json'; |
170 | 152 | const payload = { |
171 | 153 | chat_token: mudtoken, |
|
0 commit comments