Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aqerd committed Dec 2, 2024
1 parent 1eb925a commit 00e25d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/oop/project/TelegramBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.sql.SQLException;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import oop.project.services.BroadcastingService;
import org.telegram.telegrambots.meta.generics.TelegramClient;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
Expand All @@ -14,9 +15,12 @@
public class TelegramBot implements LongPollingSingleThreadUpdateConsumer {
private final ExecutorService EXECUTOR = Executors.newFixedThreadPool(10);
private static TelegramClient telegramClient = null;
private final Database database = new Database();

public TelegramBot(String botToken) throws SQLException {
telegramClient = new OkHttpTelegramClient(botToken);
BroadcastingService broadcastingService = new BroadcastingService(database, telegramClient);
BroadcastingService.startBroadcasting();
}

public static TelegramClient getTelegramClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public BroadcastingService(Database database, TelegramClient telegramClient) {
this.movieService = new MovieService();
}

public void startBroadcasting() {
public static void startBroadcasting() {
scheduler.scheduleAtFixedRate(() -> {
List<Long> subscribedUsers = database.getSubscribedUsers();
List<FilmDeserializer> upcomingMovies = movieService.getUpcomingMovies();
Expand Down

0 comments on commit 00e25d2

Please sign in to comment.