Closed Aleksandr505 closed 8 months ago
Hello, I try to configure user bot in my spring app
Bot is working great, but functions annotated as @Scheduled doesn't start. It looks like user bot is blocking this functional.
@Scheduled
Configuration bot class:
@Configuration public class TelegramUserBotConfig { @Bean @SneakyThrows public UserBot userBot( @Value("${userbot.api-id}") Integer apiId, @Value("${userbot.api-hash}") String apiHash, @Value("${userbot.phone-number}") String phoneNumber, @Value("${userbot.admin-id}") Long adminId ) { Init.init(); Log.setLogMessageHandler(1, new Slf4JLogMessageHandler()); try (SimpleTelegramClientFactory clientFactory = new SimpleTelegramClientFactory()) { APIToken apiToken = new APIToken(apiId, apiHash); TDLibSettings settings = TDLibSettings.create(apiToken); Path sessionPath = Paths.get("example-tdlight-session"); settings.setDatabaseDirectoryPath(sessionPath.resolve("data")); settings.setDownloadedFilesDirectoryPath(sessionPath.resolve("downloads")); SimpleTelegramClientBuilder clientBuilder = clientFactory.builder(settings); SimpleAuthenticationSupplier<?> authenticationData = AuthenticationSupplier.user(phoneNumber); return new UserBot(clientBuilder, authenticationData, adminId); } } }
UserBot class looks like ExampleApp class here: Example.java
This is configuration class for scheduling:
@ConditionalOnProperty( value = "app.scheduling.enable", havingValue = "true", matchIfMissing = true ) @Configuration @EnableScheduling public class SchedulingConfiguration { }
Scheduled functions which doesn't work:
@Scheduled(initialDelayString = "PT5S", fixedDelayString = "PT10M") public void scheduled() { // some scheduled code here }
This issue is not related to tdlight, sorry
Hello, I try to configure user bot in my spring app
Bot is working great, but functions annotated as
@Scheduled
doesn't start. It looks like user bot is blocking this functional.Configuration bot class:
UserBot class looks like ExampleApp class here: Example.java
This is configuration class for scheduling:
Scheduled functions which doesn't work: