add and implement config file
parent
ac689911ac
commit
29eb393717
@ -1,2 +1,3 @@
|
|||||||
./accessToken.json*
|
./accessToken.json*
|
||||||
node_app/media
|
node_app/media
|
||||||
|
node_app/config.json
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"baseUrl": "https://social.cybre.town",
|
||||||
|
"memeAPI": "http://redditapi.adb.sh/api/v1/",
|
||||||
|
"subreddits": ["r/programmerhumor/random"],
|
||||||
|
"allowedMedia": ["jpg", "jpeg", "gif", "png"],
|
||||||
|
"interval": 60
|
||||||
|
}
|
@ -1,16 +1,18 @@
|
|||||||
import {MastodonTokenHandler} from "./mastodonTokenHandler.js";
|
import {MastodonTokenHandler} from "./mastodonTokenHandler.js";
|
||||||
import {mastodonMemeBot} from "./mastodonMemeBot.js";
|
import {mastodonMemeBot} from "./mastodonMemeBot.js";
|
||||||
|
import {loadData} from "./JSONdataStore.js";
|
||||||
|
|
||||||
const config = {
|
const config = loadData("./config.json")??{
|
||||||
baseUrl: "https://social.cybre.town",
|
baseUrl: "https://social.cybre.town",
|
||||||
memeAPI: "http://redditapi.adb.sh/api/v1/",
|
memeAPI: "http://redditapi.adb.sh/api/v1/",
|
||||||
subreddits: ["r/programmerhumor/random"],
|
subreddits: ["r/programmerhumor/random"],
|
||||||
allowedMedia: ["jpg", "jpeg", "gif", "png"]
|
allowedMedia: ["jpg", "jpeg", "gif", "png"],
|
||||||
|
interval: 60
|
||||||
};
|
};
|
||||||
|
|
||||||
let tokenHandler = new MastodonTokenHandler(config.baseUrl);
|
let tokenHandler = new MastodonTokenHandler(config);
|
||||||
tokenHandler.getAccessToken((accessToken) => {
|
tokenHandler.getAccessToken((accessToken) => {
|
||||||
config.accessToken = accessToken;
|
config.accessToken = accessToken;
|
||||||
let bot = new mastodonMemeBot(config);
|
let bot = new mastodonMemeBot(config);
|
||||||
bot.setFullInterval(60);
|
bot.setFullInterval(config.interval);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue