mirror of
https://github.com/tiennm99/store-scraper-bot-java.git
synced 2026-05-15 07:53:01 +00:00
Refactor config to Environment and add Table utility
Replaces Config with Environment throughout the codebase for environment variable management. Introduces a Table utility class for formatting tabular data in bot commands, refactoring commands to use this for improved output formatting. Removes unused AppType enum. Updates test cases and build configuration for better IDE integration.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package com.miti99.storescraperbot;
|
||||
|
||||
import static com.miti99.storescraperbot.config.Config.CREATOR_ID;
|
||||
import static com.miti99.storescraperbot.config.Config.SOURCE_COMMIT;
|
||||
import static com.miti99.storescraperbot.env.Environment.CREATOR_ID;
|
||||
import static com.miti99.storescraperbot.env.Environment.SOURCE_COMMIT;
|
||||
|
||||
import com.miti99.storescraperbot.bot.StoreScrapeBot;
|
||||
import com.miti99.storescraperbot.bot.StoreScrapeBotTelegramClient;
|
||||
import com.miti99.storescraperbot.config.Config;
|
||||
import com.miti99.storescraperbot.env.Environment;
|
||||
import com.miti99.storescraperbot.repository.AdminRepository;
|
||||
import com.miti99.storescraperbot.type.Env;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplication;
|
||||
|
||||
@@ -17,10 +18,12 @@ public class Main {
|
||||
AdminRepository.INSTANCE.init();
|
||||
|
||||
try (var botsApplication = new TelegramBotsLongPollingApplication()) {
|
||||
botsApplication.registerBot(Config.TELEGRAM_BOT_TOKEN, StoreScrapeBot.INSTANCE);
|
||||
botsApplication.registerBot(Environment.TELEGRAM_BOT_TOKEN, StoreScrapeBot.INSTANCE);
|
||||
log.info("StoreScrapeBot successfully started!");
|
||||
StoreScrapeBotTelegramClient.INSTANCE.sendMessage(
|
||||
CREATOR_ID, "Bot started! Version <code>%s</code>".formatted(SOURCE_COMMIT));
|
||||
if (Environment.ENV == Env.PRODUCTION) {
|
||||
StoreScrapeBotTelegramClient.INSTANCE.sendMessage(
|
||||
CREATOR_ID, "Bot started! Version <code>%s</code>".formatted(SOURCE_COMMIT));
|
||||
}
|
||||
Thread.currentThread().join();
|
||||
} catch (Exception e) {
|
||||
log.error("Error while running bot", e);
|
||||
|
||||
Reference in New Issue
Block a user