diff --git a/pom.xml b/pom.xml
index 63eea15..213956f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,6 @@
2.15.1
1.18.30
4.12.0
- 2.0.12
@@ -44,11 +43,6 @@
jetty-util
11.0.19
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
diff --git a/src/main/java/org/telegram/BotConfig.java b/src/main/java/org/telegram/BotConfig.java
index 5c63429..1525c83 100644
--- a/src/main/java/org/telegram/BotConfig.java
+++ b/src/main/java/org/telegram/BotConfig.java
@@ -25,10 +25,10 @@ public class BotConfig {
public static final String RAE_TOKEN = "";
public static final String RAE_USER = "raebot";
- public static final String WEBHOOK_TOKEN = "";
+ public static final String WEBHOOK_TOKEN = "8660825573:AAH2wWz_3ArDL_iNoAbSxnDCs_W5brEEJ8I";
public static final String WEBHOOK_USER = "webhooksamplebot";
- public static final String COMMANDS_TOKEN = "";
+ public static final String COMMANDS_TOKEN = "8660825573:AAH2wWz_3ArDL_iNoAbSxnDCs_W5brEEJ8I";
public static final String COMMANDS_USER = "MyCommandsBot";
public static final String ELEKTROLLART_TOKEN = "";
diff --git a/src/main/java/org/telegram/BuildVars.java b/src/main/java/org/telegram/BuildVars.java
index 004bd10..22c4335 100644
--- a/src/main/java/org/telegram/BuildVars.java
+++ b/src/main/java/org/telegram/BuildVars.java
@@ -30,10 +30,10 @@ public class BuildVars {
public static final String pathToLogs = "./";
- public static final String linkDB = "jdbc:mysql://localhost:3306/YOURDATABSENAME?useUnicode=true&characterEncoding=UTF-8";
+ public static final String linkDB = "jdbc:mysql://localhost:3306/tel_example?useUnicode=true&characterEncoding=UTF-8";
public static final String controllerDB = "com.mysql.cj.jdbc.Driver";
- public static final String userDB = "";
- public static final String password = "";
+ public static final String userDB = "root";
+ public static final String password = "JtnA5H6PfGHzkfzx";
static {
// Add elements to ADMIN array here
diff --git a/src/main/java/org/telegram/Main.java b/src/main/java/org/telegram/Main.java
index 45f3238..b40b3ed 100644
--- a/src/main/java/org/telegram/Main.java
+++ b/src/main/java/org/telegram/Main.java
@@ -1,6 +1,5 @@
package org.telegram;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplication;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.webhook.TelegramBotsWebhookApplication;
@@ -19,25 +18,27 @@ import org.telegram.updateshandlers.WebHookExampleHandlers;
* @version 1.0
* Main class to create all bots
*/
-@Slf4j
public class Main {
public static void main(String[] args) {
try (TelegramBotsWebhookApplication webhookApplication = new TelegramBotsWebhookApplication(WebhookOptions.builder().enableRequestLogging(true).build())) {
- webhookApplication.registerBot(new WebHookExampleHandlers(BotConfig.WEBHOOK_TOKEN));
+// webhookApplication.registerBot(new WebHookExampleHandlers(BotConfig.WEBHOOK_TOKEN));
try (TelegramBotsLongPollingApplication botsApplication = new TelegramBotsLongPollingApplication()) {
- botsApplication.registerBot(BotConfig.WEATHER_TOKEN, new WeatherHandlers(BotConfig.WEATHER_TOKEN));
- botsApplication.registerBot(BotConfig.CHANNEL_TOKEN, new ChannelHandlers(BotConfig.CHANNEL_TOKEN));
+// botsApplication.registerBot(BotConfig.WEATHER_TOKEN, new WeatherHandlers(BotConfig.WEATHER_TOKEN));
+// botsApplication.registerBot(BotConfig.CHANNEL_TOKEN, new ChannelHandlers(BotConfig.CHANNEL_TOKEN));
botsApplication.registerBot(BotConfig.COMMANDS_TOKEN, new CommandsHandler(BotConfig.COMMANDS_TOKEN, BotConfig.COMMANDS_USER));
- botsApplication.registerBot(BotConfig.DIRECTIONS_TOKEN, new DirectionsHandlers(BotConfig.DIRECTIONS_TOKEN));
- botsApplication.registerBot(BotConfig.ELEKTROLLART_TOKEN, new ElektrollArtFanHandler(BotConfig.ELEKTROLLART_TOKEN));
- botsApplication.registerBot(BotConfig.FILES_TOKEN, new FilesHandlers(BotConfig.FILES_TOKEN));
- botsApplication.registerBot(BotConfig.RAE_TOKEN, new RaeHandlers(BotConfig.RAE_TOKEN));
+// botsApplication.registerBot(BotConfig.DIRECTIONS_TOKEN, new DirectionsHandlers(BotConfig.DIRECTIONS_TOKEN));
+// botsApplication.registerBot(BotConfig.ELEKTROLLART_TOKEN, new ElektrollArtFanHandler(BotConfig.ELEKTROLLART_TOKEN));
+// botsApplication.registerBot(BotConfig.FILES_TOKEN, new FilesHandlers(BotConfig.FILES_TOKEN));
+// botsApplication.registerBot(BotConfig.RAE_TOKEN, new RaeHandlers(BotConfig.RAE_TOKEN));
Thread.currentThread().join();
} catch (Exception e) {
- log.error("Error registering bot", e);
+// log.error("Error registering bot", e);
+ System.out.println("Error registering bot" + e);
}
} catch (TelegramApiException e) {
- log.error("Error registering bot", e);
+// log.error("Error registering bot", e);
+ System.out.println("Error registering bot" + e);
}
+ System.out.println("example bot 启动成功!");
}
}
diff --git a/src/main/java/org/telegram/commands/HelloCommand.java b/src/main/java/org/telegram/commands/HelloCommand.java
index 9d5292b..1d3030c 100644
--- a/src/main/java/org/telegram/commands/HelloCommand.java
+++ b/src/main/java/org/telegram/commands/HelloCommand.java
@@ -1,6 +1,5 @@
package org.telegram.commands;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.database.DatabaseManager;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
@@ -15,7 +14,6 @@ import org.telegram.telegrambots.meta.generics.TelegramClient;
*
* @author Timo Schulz (Mit0x2)
*/
-@Slf4j
public class HelloCommand extends BotCommand {
private static final String LOGTAG = "HELLOCOMMAND";
@@ -48,7 +46,8 @@ public class HelloCommand extends BotCommand {
try {
telegramClient.execute(answer);
} catch (TelegramApiException e) {
- log.error("Error", e);
+// log.error("Error", e);
+ System.out.println(e);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/org/telegram/commands/HelpCommand.java b/src/main/java/org/telegram/commands/HelpCommand.java
index f4d9458..66a5e70 100644
--- a/src/main/java/org/telegram/commands/HelpCommand.java
+++ b/src/main/java/org/telegram/commands/HelpCommand.java
@@ -1,6 +1,5 @@
package org.telegram.commands;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.database.DatabaseManager;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand;
@@ -16,7 +15,6 @@ import org.telegram.telegrambots.meta.generics.TelegramClient;
*
* @author Timo Schulz (Mit0x2)
*/
-@Slf4j
public class HelpCommand extends BotCommand {
private static final String LOGTAG = "HELPCOMMAND";
@@ -48,7 +46,8 @@ public class HelpCommand extends BotCommand {
try {
telegramClient.execute(helpMessage);
} catch (TelegramApiException e) {
- log.error("Error", e);
+// log.error("Error", e);
+ System.out.println(e);
}
}
}
diff --git a/src/main/java/org/telegram/commands/StartCommand.java b/src/main/java/org/telegram/commands/StartCommand.java
index b1135fb..d91addb 100644
--- a/src/main/java/org/telegram/commands/StartCommand.java
+++ b/src/main/java/org/telegram/commands/StartCommand.java
@@ -1,6 +1,5 @@
package org.telegram.commands;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.database.DatabaseManager;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
@@ -14,7 +13,6 @@ import org.telegram.telegrambots.meta.generics.TelegramClient;
*
* @author Timo Schulz (Mit0x2)
*/
-@Slf4j
public class StartCommand extends BotCommand {
public StartCommand() {
super("start", "With this command you can start the Bot");
@@ -41,7 +39,8 @@ public class StartCommand extends BotCommand {
try {
telegramClient.execute(answer);
} catch (TelegramApiException e) {
- log.error("Error", e);
+// log.error("Error", e);
+ System.out.println(e);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/org/telegram/commands/StopCommand.java b/src/main/java/org/telegram/commands/StopCommand.java
index 3cf12be..3344f1f 100644
--- a/src/main/java/org/telegram/commands/StopCommand.java
+++ b/src/main/java/org/telegram/commands/StopCommand.java
@@ -1,6 +1,5 @@
package org.telegram.commands;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.database.DatabaseManager;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
@@ -15,7 +14,6 @@ import org.telegram.telegrambots.meta.generics.TelegramClient;
*
* @author Timo Schulz (Mit0x2)
*/
-@Slf4j
public class StopCommand extends BotCommand {
public static final String LOGTAG = "STOPCOMMAND";
@@ -40,7 +38,8 @@ public class StopCommand extends BotCommand {
try {
telegramClient.execute(answer);
} catch (TelegramApiException e) {
- log.error("Error", e);
+// log.error("Error", e);
+ System.out.println("Error" + e);
}
}
}
diff --git a/src/main/java/org/telegram/commands/SuccessCommand.java b/src/main/java/org/telegram/commands/SuccessCommand.java
new file mode 100644
index 0000000..1addc1e
--- /dev/null
+++ b/src/main/java/org/telegram/commands/SuccessCommand.java
@@ -0,0 +1,43 @@
+package org.telegram.commands;
+
+import org.telegram.database.DatabaseManager;
+import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand;
+import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
+import org.telegram.telegrambots.meta.api.objects.Chat;
+import org.telegram.telegrambots.meta.api.objects.User;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
+import org.telegram.telegrambots.meta.generics.TelegramClient;
+
+/**
+ * This command returns the username + success message
+ *
+ * @author Your Name
+ */
+public class SuccessCommand extends BotCommand {
+
+ private static final String LOGTAG = "SUCCESSCOMMAND";
+
+ public SuccessCommand() {
+ super("success", "Get your success message");
+ }
+
+ @Override
+ public void execute(TelegramClient telegramClient, User user, Chat chat, String[] arguments) {
+
+ if (!DatabaseManager.getInstance().getUserStateForCommandsBot(user.getId())) {
+ return;
+ }
+
+ String userName = user.getFirstName() + " " + user.getLastName();
+ String messageText = userName + " success";
+
+ SendMessage answer = new SendMessage(chat.getId().toString(), messageText);
+
+ try {
+ telegramClient.execute(answer);
+ } catch (TelegramApiException e) {
+// log.error("Error", e);
+ System.out.println(e);
+ }
+ }
+}
diff --git a/src/main/java/org/telegram/database/ConnectionDB.java b/src/main/java/org/telegram/database/ConnectionDB.java
index 0c2c076..ed40816 100644
--- a/src/main/java/org/telegram/database/ConnectionDB.java
+++ b/src/main/java/org/telegram/database/ConnectionDB.java
@@ -7,7 +7,6 @@
*/
package org.telegram.database;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.BuildVars;
import java.lang.reflect.InvocationTargetException;
@@ -24,7 +23,6 @@ import java.sql.Statement;
* @version 2.0
* Connector to database
*/
-@Slf4j
public class ConnectionDB {
private final Connection currentConection;
@@ -39,7 +37,8 @@ public class ConnectionDB {
connection = DriverManager.getConnection(BuildVars.linkDB, BuildVars.userDB, BuildVars.password);
} catch (SQLException | ClassNotFoundException | IllegalAccessException | InstantiationException |
NoSuchMethodException | InvocationTargetException e) {
- log.error("Error opening connection", e);
+// log.error("Error opening connection", e);
+ System.out.println("Error opening connection" + e);
}
return connection;
@@ -49,7 +48,8 @@ public class ConnectionDB {
try {
this.currentConection.close();
} catch (SQLException e) {
- log.error("Error closing the connection", e);
+// log.error("Error closing the connection", e);
+ System.out.println("Error closing the connection" + e);
}
}
@@ -89,7 +89,8 @@ public class ConnectionDB {
}
}
} catch (SQLException e) {
- log.error("Error checking version", e);
+// log.error("Error checking version", e);
+ System.out.println("Error checking version" + e);
}
return max;
}
@@ -122,7 +123,8 @@ public class ConnectionDB {
try {
this.currentConection.rollback();
} catch (SQLException e) {
- log.error("Error rolling back the transaction", e);
+// log.error("Error rolling back the transaction", e);
+ System.out.println("Error rolling back the transaction" + e);
} finally {
this.currentConection.setAutoCommit(true);
}
diff --git a/src/main/java/org/telegram/database/DatabaseManager.java b/src/main/java/org/telegram/database/DatabaseManager.java
index b8262c4..de5976b 100644
--- a/src/main/java/org/telegram/database/DatabaseManager.java
+++ b/src/main/java/org/telegram/database/DatabaseManager.java
@@ -7,7 +7,6 @@
*/
package org.telegram.database;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.structure.WeatherAlert;
import java.sql.PreparedStatement;
@@ -23,7 +22,6 @@ import java.util.List;
* @version 2.0
* Database Manager to perform database operations
*/
-@Slf4j
public class DatabaseManager {
private static volatile DatabaseManager instance;
private static volatile ConnectionDB connetion;
@@ -34,7 +32,8 @@ public class DatabaseManager {
private DatabaseManager() {
connetion = new ConnectionDB();
final int currentVersion = connetion.checkVersion();
- log.info("Current db version: " + currentVersion);
+// log.info("Current db version: " + currentVersion);
+ System.out.println("Current db version: " + currentVersion);
if (currentVersion < CreationStrings.version) {
recreateTable(currentVersion);
}
@@ -95,11 +94,13 @@ public class DatabaseManager {
}
connetion.commitTransaction();
} catch (SQLException e) {
- log.error("Error updating DB", e);
+// log.error("Error updating DB", e);
+ System.out.println("Error updating DB" + e);
try {
connetion.rollbackTransaction();
} catch (SQLException ex) {
- log.error("Error rollingback the transaction", ex);
+// log.error("Error rollingback the transaction", ex);
+ System.out.println("Error rollingback the transaction" + ex);
}
}
}
@@ -187,7 +188,8 @@ public class DatabaseManager {
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error setting user state for commands bot", e);
+// log.error("Error setting user state for commands bot", e);
+ System.out.println("Error setting user state for commands bot" + e);
}
return updatedRows > 0;
}
@@ -202,7 +204,8 @@ public class DatabaseManager {
status = result.getInt("status");
}
} catch (SQLException e) {
- log.error("Error getting user state for command bot", e);
+// log.error("Error getting user state for command bot", e);
+ System.out.println("Error getting user state for command bot" + e);
}
return status == 1;
}
@@ -217,7 +220,8 @@ public class DatabaseManager {
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error getting file", e);
+// log.error("Error getting file", e);
+ System.out.println("Error getting file" + e);
}
return updatedRows > 0;
}
@@ -233,7 +237,7 @@ public class DatabaseManager {
}
result.close();
} catch (SQLException e) {
- log.error("Error getting files for user", e);
+ System.out.println("Error getting files for user" + e);
}
return files;
}
@@ -246,7 +250,7 @@ public class DatabaseManager {
preparedStatement.setInt(2, status);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error getting user for file", e);
+ System.out.println("Error getting user for file" + e);
}
return updatedRows > 0;
}
@@ -259,7 +263,7 @@ public class DatabaseManager {
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error deleting user file", e);
+ System.out.println("Error deleting user file" + e);
}
return updatedRows > 0;
}
@@ -274,7 +278,7 @@ public class DatabaseManager {
status = result.getInt("status");
}
} catch (SQLException e) {
- log.error("Error getting user status", e);
+ System.out.println("Error getting user status" + e);
}
return status;
}
@@ -287,7 +291,7 @@ public class DatabaseManager {
final ResultSet result = preparedStatement.executeQuery();
exists = result.next();
} catch (SQLException e) {
- log.error("Error checking file", e);
+ System.out.println("Error checking file" + e);
}
return exists;
}
@@ -300,7 +304,7 @@ public class DatabaseManager {
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error deleting files", e);
+ System.out.println("Error deleting files" + e);
}
return updatedRows > 0;
}
@@ -314,7 +318,7 @@ public class DatabaseManager {
preparedStatement.setString(3, cityName);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error adding recent weather", e);
+ System.out.println("Error adding recent weather" + e);
}
cleanUpRecent(userId);
return updatedRows > 0;
@@ -330,7 +334,7 @@ public class DatabaseManager {
recentWeather.add(result.getString("cityName"));
}
} catch (SQLException e) {
- log.error("Error getting recent weather", e);
+ System.out.println("Error getting recent weather" + e);
}
return recentWeather;
@@ -343,7 +347,7 @@ public class DatabaseManager {
preparedStatement.setLong(2, userId);
preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error cleaning up recent user", e);
+ System.out.println("Error cleaning up recent user" + e);
}
}
@@ -361,7 +365,7 @@ public class DatabaseManager {
}
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error adding user for direction", e);
+ System.out.println("Error adding user for direction" + e);
}
return updatedRows > 0;
}
@@ -376,7 +380,7 @@ public class DatabaseManager {
status = result.getInt("status");
}
} catch (SQLException e) {
- log.error("Error getting user destination status", e);
+ System.out.println("Error getting user destination status" + e);
}
return status;
}
@@ -391,7 +395,7 @@ public class DatabaseManager {
messageId = result.getInt("messageId");
}
} catch (SQLException e) {
- log.error("Error getting user destination message id", e);
+ System.out.println("Error getting user destination message id" + e);
}
return messageId;
}
@@ -406,7 +410,7 @@ public class DatabaseManager {
origin = result.getString("origin");
}
} catch (SQLException e) {
- log.error("Error get user origin", e);
+ System.out.println("Error get user origin" + e);
}
return origin;
}
@@ -419,7 +423,7 @@ public class DatabaseManager {
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error deleting user directions", e);
+ System.out.println("Error deleting user directions" + e);
}
return updatedRows > 0;
}
@@ -432,7 +436,7 @@ public class DatabaseManager {
preparedStatement.setInt(2, updateId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error adding last update", e);
+ System.out.println("Error adding last update" + e);
}
return updatedRows > 0;
}
@@ -447,7 +451,7 @@ public class DatabaseManager {
updateId = result.getInt("updateId");
}
} catch (SQLException e) {
- log.error("Error getting last update", e);
+ System.out.println("Error getting last update" + e);
}
return updateId;
}
@@ -462,7 +466,7 @@ public class DatabaseManager {
languageCode = result.getString("languageCode");
}
} catch (SQLException e) {
- log.error("Error getting user language", e);
+ System.out.println("Error getting user language" + e);
}
return languageCode;
}
@@ -475,7 +479,7 @@ public class DatabaseManager {
preparedStatement.setString(2, language);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error updating user language", e);
+ System.out.println("Error updating user language" + e);
}
return updatedRows > 0;
}
@@ -491,7 +495,7 @@ public class DatabaseManager {
state = result.getInt("state");
}
} catch (SQLException e) {
- log.error("Error getting weather state", e);
+ System.out.println("Error getting weather state" + e);
}
return state;
}
@@ -505,7 +509,7 @@ public class DatabaseManager {
preparedStatement.setInt(3, state);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error insert weather state", e);
+ System.out.println("Error insert weather state" + e);
}
return updatedRows > 0;
}
@@ -521,7 +525,7 @@ public class DatabaseManager {
cityId = result.getInt("cityId");
}
} catch (SQLException e) {
- log.error("Error getting recent weather by city", e);
+ System.out.println("Error getting recent weather by city" + e);
}
return cityId;
@@ -540,7 +544,7 @@ public class DatabaseManager {
addNewUserWeatherOptions(userId);
}
} catch (SQLException e) {
- log.error("Error getting wether options", e);
+ System.out.println("Error getting wether options" + e);
}
return options;
}
@@ -552,7 +556,7 @@ public class DatabaseManager {
preparedStatement.setLong(1, userId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error adding new user weather options", e);
+ System.out.println("Error adding new user weather options" + e);
}
return updatedRows > 0;
}
@@ -565,7 +569,7 @@ public class DatabaseManager {
preparedStatement.setLong(2, userId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error updating weather language options", e);
+ System.out.println("Error updating weather language options" + e);
}
return updatedRows > 0;
}
@@ -578,7 +582,7 @@ public class DatabaseManager {
preparedStatement.setLong(2, userId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error adding weather unit option", e);
+ System.out.println("Error adding weather unit option" + e);
}
return updatedRows > 0;
}
@@ -592,7 +596,7 @@ public class DatabaseManager {
preparedStatement.setString(3, cityName);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error creating weather alert", e);
+ System.out.println("Error creating weather alert" + e);
}
return updatedRows > 0;
}
@@ -607,7 +611,7 @@ public class DatabaseManager {
alertCitiesNames.add(result.getString("cityName"));
}
} catch (SQLException e) {
- log.error("Error getting alerts by user", e);
+ System.out.println("Error getting alerts by user" + e);
}
return alertCitiesNames;
@@ -621,7 +625,7 @@ public class DatabaseManager {
preparedStatement.setString(2, cityName);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error delete city alert", e);
+ System.out.println("Error delete city alert" + e);
}
return updatedRows > 0;
}
@@ -633,7 +637,7 @@ public class DatabaseManager {
preparedStatement.setLong(1, userId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
- log.error("Error deleting alerts for user", e);
+ System.out.println("Error deleting alerts for user" + e);
}
return updatedRows > 0;
}
@@ -652,7 +656,7 @@ public class DatabaseManager {
allAlerts.add(weatherAlert);
}
} catch (SQLException e) {
- log.error("Error getting all alerts", e);
+ System.out.println("Error getting all alerts" + e);
}
return allAlerts;
diff --git a/src/main/java/org/telegram/services/DirectionsService.java b/src/main/java/org/telegram/services/DirectionsService.java
index 461a86c..ae846f3 100644
--- a/src/main/java/org/telegram/services/DirectionsService.java
+++ b/src/main/java/org/telegram/services/DirectionsService.java
@@ -1,6 +1,5 @@
package org.telegram.services;
-import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -22,7 +21,6 @@ import java.util.List;
* @version 1.0
* Weather service
*/
-@Slf4j
public class DirectionsService {
private static final String BASEURL = "https://maps.googleapis.com/maps/api/directions/json"; ///< Base url for REST
private static final String APIIDEND = "&key=" + BuildVars.DirectionsApiKey;
@@ -101,7 +99,8 @@ public class DirectionsService {
}
}
} catch (Exception e) {
- log.warn("Error getting directions", e);
+// log.warn("Error getting directions", e);
+ System.out.println("Error getting directions" + e);
responseToUser.add(LocalisationService.getString("errorFetchingDirections", language));
}
return responseToUser;
diff --git a/src/main/java/org/telegram/services/RaeService.java b/src/main/java/org/telegram/services/RaeService.java
index 6bc8990..d713788 100644
--- a/src/main/java/org/telegram/services/RaeService.java
+++ b/src/main/java/org/telegram/services/RaeService.java
@@ -1,6 +1,5 @@
package org.telegram.services;
-import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -24,7 +23,6 @@ import java.util.Objects;
* @version 1.0
* Rae service
*/
-@Slf4j
public class RaeService {
private static final String BASEURL = "http://dle.rae.es/srv/"; ///< Base url for REST
private static final String SEARCHEXACTURL = "search?m=30&w=";
@@ -69,7 +67,8 @@ public class RaeService {
}
}
} catch (IOException e) {
- log.error("Error getting RAE results", e);
+// log.error("Error getting RAE results", e);
+ System.out.println("Error getting RAE results" + e);
}
return results;
@@ -111,7 +110,8 @@ public class RaeService {
}
}
} catch (IOException e) {
- log.error("Error getting results from search", e);
+// log.error("Error getting results from search", e);
+ System.out.println("Error getting results from search" + e);
}
return results;
@@ -150,7 +150,8 @@ public class RaeService {
}
}
} catch (IOException e) {
- log.error("Fetching words", e);
+// log.error("Fetching words", e);
+ System.out.println("Fetching words" + e);
}
return results;
diff --git a/src/main/java/org/telegram/services/TimerExecutor.java b/src/main/java/org/telegram/services/TimerExecutor.java
index 47fc7c1..31e9021 100644
--- a/src/main/java/org/telegram/services/TimerExecutor.java
+++ b/src/main/java/org/telegram/services/TimerExecutor.java
@@ -1,7 +1,5 @@
package org.telegram.services;
-import lombok.extern.slf4j.Slf4j;
-
import java.time.Clock;
import java.time.Duration;
import java.time.LocalDateTime;
@@ -14,7 +12,6 @@ import java.util.concurrent.TimeUnit;
* @version 2.0
* Execute a task periodically
*/
-@Slf4j
public class TimerExecutor {
private static volatile TimerExecutor instance; ///< Instance
private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); ///< Thread to execute operations
@@ -55,14 +52,16 @@ public class TimerExecutor {
* @param targetSec Second to execute it
*/
public void startExecutionEveryDayAt(CustomTimerTask task, int targetHour, int targetMin, int targetSec) {
- log.warn("Posting new task {}", task.getTaskName());
+// log.warn("Posting new task {}", task.getTaskName());
+ System.out.println("Posting new task " + task.getTaskName());
final Runnable taskWrapper = () -> {
try {
task.execute();
task.reduceTimes();
startExecutionEveryDayAt(task, targetHour, targetMin, targetSec);
} catch (Exception e) {
- log.error("Bot threw an unexpected exception at TimerExecutor", e);
+// log.error("Bot threw an unexpected exception at TimerExecutor", e);
+ System.out.println("Bot threw an unexpected exception at TimerExecutor" + e);
}
};
if (task.getTimes() != 0) {
@@ -103,9 +102,11 @@ public class TimerExecutor {
try {
executorService.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException ex) {
- log.error("Task interrupted", ex);
+// log.error("Task interrupted", ex);
+ System.out.println("Task interrupted" + ex);
} catch (Exception e) {
- log.error("Bot threw an unexpected exception at TimerExecutor", e);
+// log.error("Bot threw an unexpected exception at TimerExecutor", e);
+ System.out.println("Bot threw an unexpected exception at TimerExecutor" + e);
}
}
}
diff --git a/src/main/java/org/telegram/services/WeatherService.java b/src/main/java/org/telegram/services/WeatherService.java
index f40806a..2110c4f 100644
--- a/src/main/java/org/telegram/services/WeatherService.java
+++ b/src/main/java/org/telegram/services/WeatherService.java
@@ -1,6 +1,5 @@
package org.telegram.services;
-import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -22,7 +21,6 @@ import java.time.format.DateTimeFormatter;
* @version 1.0
* Weather service
*/
-@Slf4j
public class WeatherService {
public static final String METRICSYSTEM = "metric";
public static final String IMPERIALSYSTEM = "imperial";
@@ -89,7 +87,8 @@ public class WeatherService {
try (ResponseBody body = response.body()) {
if (body != null) {
JSONObject jsonObject = new JSONObject(body.string());
- log.info("Alert fetched: {}", jsonObject);
+// log.info("Alert fetched: {}", jsonObject);
+ System.out.println("Alert fetched: " + jsonObject);
if (jsonObject.getInt("cod") == 200) {
cityFound = jsonObject.getJSONObject("city").getString("name") + " (" +
jsonObject.getJSONObject("city").getString("country") + ")";
@@ -97,7 +96,7 @@ public class WeatherService {
responseToUser = String.format(LocalisationService.getString("weatherAlert", language),
cityFound, convertListOfForecastToString(jsonObject, language, units, false));
} else {
- log.warn("Unable to read alerts fetched {}", jsonObject);
+ System.out.println("Unable to read alerts fetched " + jsonObject);
responseToUser = LocalisationService.getString("cityNotFound", language);
}
} else {
@@ -109,7 +108,7 @@ public class WeatherService {
}
}
} catch (Exception e) {
- log.error("Error fetching alerts", e);
+ System.out.println("Error fetching alerts" + e);
responseToUser = LocalisationService.getString("errorFetchingWeather", language);
}
return responseToUser;
@@ -139,7 +138,7 @@ public class WeatherService {
try (ResponseBody body = response.body()) {
if (body != null) {
JSONObject jsonObject = new JSONObject(body.string());
- log.info("Fetched weather forecast {}", jsonObject);
+ System.out.println("Fetched weather forecast " + jsonObject);
if (jsonObject.getInt("cod") == 200) {
cityFound = jsonObject.getJSONObject("city").getString("name") + " (" +
jsonObject.getJSONObject("city").getString("country") + ")";
@@ -147,7 +146,7 @@ public class WeatherService {
responseToUser = String.format(LocalisationService.getString("weatherForcast", language),
cityFound, convertListOfForecastToString(jsonObject, language, units, true));
} else {
- log.warn("City forecast not found {}", jsonObject);
+ System.out.println("City forecast not found " + jsonObject);
responseToUser = LocalisationService.getString("cityNotFound", language);
}
} else {
@@ -159,7 +158,7 @@ public class WeatherService {
}
}
} catch (Exception e) {
- log.error("Error fetching city forecast", e);
+ System.out.println("Error fetching city forecast" + e);
responseToUser = LocalisationService.getString("errorFetchingWeather", language);
}
return responseToUser;
@@ -196,7 +195,7 @@ public class WeatherService {
responseToUser = String.format(LocalisationService.getString("weatherForcast", language),
cityFound, convertListOfForecastToString(jsonObject, language, units, true));
} else {
- log.warn("No forecast for location found {}", jsonObject);
+ System.out.println("No forecast for location found " + jsonObject);
responseToUser = LocalisationService.getString("cityNotFound", language);
}
} else {
@@ -208,7 +207,7 @@ public class WeatherService {
}
}
} catch (Exception e) {
- log.error("Error fetching location forecast", e);
+ System.out.println("Error fetching location forecast" + e);
responseToUser = LocalisationService.getString("errorFetchingWeather", language);
}
return responseToUser;
@@ -247,7 +246,7 @@ public class WeatherService {
responseToUser = String.format(LocalisationService.getString("weatherCurrent", language),
cityFound, convertCurrentWeatherToString(jsonObject, language, units, emoji));
} else {
- log.warn("No current weather found {}", jsonObject);
+ System.out.println("No current weather found " + jsonObject);
responseToUser = LocalisationService.getString("cityNotFound", language);
}
} else {
@@ -259,7 +258,7 @@ public class WeatherService {
}
}
} catch (Exception e) {
- log.error("Error fetching current weather", e);
+ System.out.println("Error fetching current weather" + e);
responseToUser = LocalisationService.getString("errorFetchingWeather", language);
}
return responseToUser;
@@ -296,7 +295,7 @@ public class WeatherService {
responseToUser = String.format(LocalisationService.getString("weatherCurrent", language),
cityFound, convertCurrentWeatherToString(jsonObject, language, units, null));
} else {
- log.warn("No weather found for location {}", jsonObject);
+ System.out.println("No weather found for location " + jsonObject);
responseToUser = LocalisationService.getString("cityNotFound", language);
}
} else {
@@ -308,7 +307,7 @@ public class WeatherService {
}
}
} catch (Exception e) {
- log.error("Error fetching weather for location", e);
+ System.out.println("Error fetching weather for location" + e);
responseToUser = LocalisationService.getString("errorFetchingWeather", language);
}
return responseToUser;
diff --git a/src/main/java/org/telegram/updateshandlers/ChannelHandlers.java b/src/main/java/org/telegram/updateshandlers/ChannelHandlers.java
index 5388f5e..bbbe3e4 100644
--- a/src/main/java/org/telegram/updateshandlers/ChannelHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/ChannelHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
import org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
@@ -20,7 +19,6 @@ import java.util.concurrent.ConcurrentHashMap;
* Handler for updates to channel updates bot
* This is a use case that will send a message to a channel if it is added as an admin to it.
*/
-@Slf4j
public class ChannelHandlers implements LongPollingSingleThreadUpdateConsumer {
private static final int WAITINGCHANNEL = 1;
@@ -46,11 +44,13 @@ public class ChannelHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
handleIncomingMessage(message);
} catch (InvalidObjectException e) {
- log.error("Channel Handler Error", e);
+// log.error("Channel Handler Error", e);
+ System.out.println("Channel Handler Error" + e);
}
}
} catch (Exception e) {
- log.error("Error handling channel message", e);
+// log.error("Error handling channel message", e);
+ System.out.println("Error handling channel message" + e);
}
}
@@ -84,7 +84,8 @@ public class ChannelHandlers implements LongPollingSingleThreadUpdateConsumer {
}
}
} catch (TelegramApiException e) {
- log.error("Error waiting channel message", e);
+// log.error("Error waiting channel message", e);
+ System.out.println("Error waiting channel message" + e);
}
}
@@ -108,7 +109,8 @@ public class ChannelHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
telegramClient.execute(sendMessage);
} catch (TelegramApiException e) {
- log.error("Error sending error message", e);
+// log.error("Error sending error message", e);
+ System.out.println("Error sending error message" + e);
}
}
@@ -142,7 +144,8 @@ public class ChannelHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
telegramClient.execute(sendMessage);
} catch (TelegramApiException e) {
- log.error("Error sending help message", e);
+// log.error("Error sending help message", e);
+ System.out.println("Error sending help message" + e);
}
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/CommandsHandler.java b/src/main/java/org/telegram/updateshandlers/CommandsHandler.java
index 57d8faf..45777c6 100644
--- a/src/main/java/org/telegram/updateshandlers/CommandsHandler.java
+++ b/src/main/java/org/telegram/updateshandlers/CommandsHandler.java
@@ -1,10 +1,10 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.commands.HelloCommand;
import org.telegram.commands.HelpCommand;
import org.telegram.commands.StartCommand;
import org.telegram.commands.StopCommand;
+import org.telegram.commands.SuccessCommand;
import org.telegram.database.DatabaseManager;
import org.telegram.services.Emoji;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
@@ -19,7 +19,6 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
*
* @author Timo Schulz (Mit0x2)
*/
-@Slf4j
public class CommandsHandler extends CommandLongPollingTelegramBot {
/**
* Constructor.
@@ -29,6 +28,7 @@ public class CommandsHandler extends CommandLongPollingTelegramBot {
register(new HelloCommand());
register(new StartCommand());
register(new StopCommand());
+ register(new SuccessCommand());
HelpCommand helpCommand = new HelpCommand(this);
register(helpCommand);
@@ -38,7 +38,8 @@ public class CommandsHandler extends CommandLongPollingTelegramBot {
try {
telegramClient.execute(commandUnknownMessage);
} catch (TelegramApiException e) {
- log.error("Error sending message in commands bot", e);
+// log.error("Error sending message in commands bot", e);
+ System.out.println("Error sending message in commands bot" + e);
}
helpCommand.execute(telegramClient, message.getFrom(), message.getChat(), new String[] {});
});
@@ -58,7 +59,8 @@ public class CommandsHandler extends CommandLongPollingTelegramBot {
try {
telegramClient.execute(echoMessage);
} catch (TelegramApiException e) {
- log.error("Error processing non-command update", e);
+// log.error("Error processing non-command update", e);
+ System.out.println("Error processing non-command update" + e);
}
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/DirectionsHandlers.java b/src/main/java/org/telegram/updateshandlers/DirectionsHandlers.java
index 8e38b50..f9617d1 100644
--- a/src/main/java/org/telegram/updateshandlers/DirectionsHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/DirectionsHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.Commands;
import org.telegram.database.DatabaseManager;
import org.telegram.services.DirectionsService;
@@ -27,7 +26,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* @version 1.0
* Handler for updates to Directions Bot
*/
-@Slf4j
public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer {
private static final int WATING_ORIGIN_STATUS = 0;
private static final int WATING_DESTINY_STATUS = 1;
@@ -43,7 +41,8 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
try {
handleDirections(update);
} catch (Exception e) {
- log.error("Error processing update in directions bot", e);
+// log.error("Error processing update in directions bot", e);
+ System.out.println("Error processing update in directions bot" + e);
}
}
@@ -80,7 +79,7 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
try {
telegramClient.execute(sendMessageRequest);
} catch (TelegramApiException e) {
- log.error("Error handling directions", e);
+ System.out.println("Error handling directions" + e);
}
}
}
@@ -105,9 +104,9 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
if (sentMessage != null) {
DatabaseManager.getInstance().deleteUserForDirections(message.getFrom().getId());
}
- }).thenAccept(unused -> log.info("Sent destination received"));
+ }).thenAccept(unused -> System.out.println("Sent destination received"));
} catch (TelegramApiException e) {
- log.error("Error on destination received", e);
+ System.out.println("Error on destination received" + e);
}
}
@@ -126,9 +125,9 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
DatabaseManager.getInstance().addUserForDirection(message.getFrom().getId(), WATING_DESTINY_STATUS,
sentMessage.getMessageId(), message.getText());
}
- }).thenAccept(unused -> log.info("Sent origin received"));
+ }).thenAccept(unused -> System.out.println("Sent origin received"));
} catch (TelegramApiException e) {
- log.error("Error on origin received", e);
+ System.out.println("Error on origin received" + e);
}
}
@@ -140,7 +139,7 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
try {
telegramClient.execute(sendMessageRequest);
} catch (TelegramApiException e) {
- log.error("Error sending help", e);
+ System.out.println("Error sending help" + e);
}
}
@@ -156,9 +155,9 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
DatabaseManager.getInstance().addUserForDirection(message.getFrom().getId(), WATING_ORIGIN_STATUS,
sentMessage.getMessageId(), null);
}
- }).thenAccept(unused -> log.info("Sent start directions"));
+ }).thenAccept(unused -> System.out.println("Sent start directions"));
} catch (TelegramApiException e) {
- log.error("Error on start directions", e);
+ System.out.println("Error on start directions" + e);
}
}
@@ -181,7 +180,7 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
telegramClient.execute(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
} catch (TelegramApiException e) {
- log.error("Error setting language", e);
+ System.out.println("Error setting language" + e);
}
}
@@ -202,7 +201,7 @@ public class DirectionsHandlers implements LongPollingSingleThreadUpdateConsumer
telegramClient.execute(sendMessageRequestBuilder.build());
languageMessages.remove(message.getFrom().getId());
} catch (TelegramApiException e) {
- log.error("Error on lanaguage selected", e);
+ System.out.println("Error on lanaguage selected" + e);
}
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/ElektrollArtFanHandler.java b/src/main/java/org/telegram/updateshandlers/ElektrollArtFanHandler.java
index 9211fcf..1858e86 100644
--- a/src/main/java/org/telegram/updateshandlers/ElektrollArtFanHandler.java
+++ b/src/main/java/org/telegram/updateshandlers/ElektrollArtFanHandler.java
@@ -1,7 +1,6 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
import org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer;
import org.telegram.telegrambots.meta.api.methods.AnswerCallbackQuery;
@@ -26,7 +25,6 @@ import java.util.ArrayList;
* This bot is an example for using inline buttons, here to make a gallery.
* Bot contains some images from ElektrollArt that are all licensed under creative commons
*/
-@Slf4j
public class ElektrollArtFanHandler implements LongPollingSingleThreadUpdateConsumer {
private final ArrayList urls;
@@ -90,7 +88,8 @@ public class ElektrollArtFanHandler implements LongPollingSingleThreadUpdateCons
try {
telegramClient.execute(sendMessagerequest);
} catch (TelegramApiException e) {
- log.error("Error sending start message", e);
+// log.error("Error sending start message", e);
+ System.out.println("Error sending start message" + e);
}
}
}
@@ -117,7 +116,8 @@ public class ElektrollArtFanHandler implements LongPollingSingleThreadUpdateCons
try {
this.sendAnswerCallbackQuery("Please use one of the given actions below, instead.", false, callbackquery);
} catch (TelegramApiException e) {
- log.error("Send text response", e);
+// log.error("Send text response", e);
+ System.out.println("Send text response" + e);
}
}
@@ -125,7 +125,8 @@ public class ElektrollArtFanHandler implements LongPollingSingleThreadUpdateCons
try {
this.sendAnswerCallbackQuery(INDEX_OUT_OF_RANGE, false, callbackquery);
} catch (TelegramApiException e) {
- log.error("Send index out of range response", e);
+// log.error("Send index out of range response", e);
+ System.out.println("Send index out of range response" + e);
}
} else {
@@ -138,7 +139,8 @@ public class ElektrollArtFanHandler implements LongPollingSingleThreadUpdateCons
try {
telegramClient.execute(editMarkup);
} catch (TelegramApiException e) {
- log.error("Error updating markup", e);
+// log.error("Error updating markup", e);
+ System.out.println("Error updating markup" + e);
}
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/FilesHandlers.java b/src/main/java/org/telegram/updateshandlers/FilesHandlers.java
index cb8e73d..e6fca40 100644
--- a/src/main/java/org/telegram/updateshandlers/FilesHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/FilesHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.Commands;
import org.telegram.database.DatabaseManager;
import org.telegram.services.Emoji;
@@ -32,7 +31,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* Handler for updates to Files Bot
* This bot is an example for the use of sendMessage asynchronously
*/
-@Slf4j
public class FilesHandlers implements LongPollingSingleThreadUpdateConsumer {
private static final int INITIAL_UPLOAD_STATUS = 0;
private static final int DELETE_UPLOADED_STATUS = 1;
@@ -56,11 +54,13 @@ public class FilesHandlers implements LongPollingSingleThreadUpdateConsumer {
}
}
} catch (Exception e) {
- log.error("Error handling file update", e);
+// log.error("Error handling file update", e);
+ System.out.println("Error handling file update" + e);
}
}
} catch (Exception e) {
- log.error("Unknown exception", e);
+// log.error("Unknown exception", e);
+ System.out.println("Unknown exception" + e);
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/RaeHandlers.java b/src/main/java/org/telegram/updateshandlers/RaeHandlers.java
index 60f977e..a8348fb 100644
--- a/src/main/java/org/telegram/updateshandlers/RaeHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/RaeHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.services.RaeService;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
import org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer;
@@ -24,7 +23,6 @@ import java.util.List;
* @version 1.0
* Handler for inline queries in Raebot
*/
-@Slf4j
public class RaeHandlers implements LongPollingSingleThreadUpdateConsumer {
private static final Integer CACHETIME = 86400;
private final RaeService raeService = new RaeService();
@@ -51,11 +49,13 @@ public class RaeHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
telegramClient.execute(getHelpMessage(update.getMessage()));
} catch (TelegramApiException e) {
- log.error("Error", e);
+// log.error("Error", e);
+ System.out.println("Error" + e);
}
}
} catch (Exception e) {
- log.error("Unknown exception", e);
+// log.error("Unknown exception", e);
+ System.out.println("Error" + e);
}
}
@@ -65,7 +65,8 @@ public class RaeHandlers implements LongPollingSingleThreadUpdateConsumer {
*/
private void handleIncomingInlineQuery(InlineQuery inlineQuery) {
String query = inlineQuery.getQuery();
- log.debug("Searching: {}", query);
+// log.debug("Searching: {}", query);
+ System.out.println("Searching: " + query);
try {
if (!query.isEmpty()) {
List results = raeService.getResults(query);
@@ -74,7 +75,8 @@ public class RaeHandlers implements LongPollingSingleThreadUpdateConsumer {
telegramClient.execute(converteResultsToResponse(inlineQuery, new ArrayList<>()));
}
} catch (TelegramApiException e) {
- log.error("Error handing inline query", e);
+// log.error("Error handing inline query", e);
+ System.out.println("Error handing inline query" + e);
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/WeatherHandlers.java b/src/main/java/org/telegram/updateshandlers/WeatherHandlers.java
index aaf63e8..66e5bbf 100644
--- a/src/main/java/org/telegram/updateshandlers/WeatherHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/WeatherHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.Commands;
import org.telegram.database.DatabaseManager;
import org.telegram.services.CustomTimerTask;
@@ -32,7 +31,6 @@ import java.util.List;
* @version 1.0
* Handler for updates to Weather Bot
*/
-@Slf4j
public class WeatherHandlers implements LongPollingSingleThreadUpdateConsumer {
private static final int STARTSTATE = 0;
private static final int MAINMENU = 1;
@@ -66,7 +64,8 @@ public class WeatherHandlers implements LongPollingSingleThreadUpdateConsumer {
}
}
} catch (Exception e) {
- log.error("Weather Handler error", e);
+// log.error("Weather Handler error", e);
+ System.out.println("Weather Handler error" + e);
}
}
@@ -93,7 +92,8 @@ public class WeatherHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
Thread.currentThread().wait(35);
} catch (InterruptedException e) {
- log.error("Error sleeping for alerts", e);
+// log.error("Error sleeping for alerts", e);
+ System.out.println("Error sleeping for alerts" + e);
}
}
String[] userOptions = DatabaseManager.getInstance().getUserWeatherOptions(weatherAlert.getUserId());
@@ -104,12 +104,14 @@ public class WeatherHandlers implements LongPollingSingleThreadUpdateConsumer {
try {
telegramClient.execute(sendMessage);
} catch (TelegramApiRequestException e) {
- log.warn("Error sending alerts", e);
+// log.warn("Error sending alerts", e);
+ System.out.println("Error sending alerts" + e);
if (e.getApiResponse().contains("Can't access the chat") || e.getApiResponse().contains("Bot was blocked by the user")) {
DatabaseManager.getInstance().deleteAlertsForUser(weatherAlert.getUserId());
}
} catch (Exception e) {
- log.error("Unknown error sending alerts", e);
+// log.error("Unknown error sending alerts", e);
+ System.out.println("Unknown error sending alerts" + e);
}
}
}
diff --git a/src/main/java/org/telegram/updateshandlers/WebHookExampleHandlers.java b/src/main/java/org/telegram/updateshandlers/WebHookExampleHandlers.java
index c570c37..847a7fe 100644
--- a/src/main/java/org/telegram/updateshandlers/WebHookExampleHandlers.java
+++ b/src/main/java/org/telegram/updateshandlers/WebHookExampleHandlers.java
@@ -1,6 +1,5 @@
package org.telegram.updateshandlers;
-import lombok.extern.slf4j.Slf4j;
import org.telegram.BotConfig;
import org.telegram.BuildVars;
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
@@ -18,7 +17,6 @@ import org.telegram.telegrambots.webhook.TelegramWebhookBot;
* @version 1.0
* Simple Webhook example
*/
-@Slf4j
public class WebHookExampleHandlers implements TelegramWebhookBot {
private final TelegramClient telegramClient;
@@ -44,7 +42,8 @@ public class WebHookExampleHandlers implements TelegramWebhookBot {
try {
telegramClient.execute(new DeleteWebhook());
} catch (TelegramApiException e) {
- log.info("Error deleting webhook");
+// log.info("Error deleting webhook");
+ System.out.println("Error deleting webhook" + e);
}
}
@@ -56,7 +55,8 @@ public class WebHookExampleHandlers implements TelegramWebhookBot {
.url(BuildVars.EXTERNALWEBHOOKURL + getBotPath())
.build());
} catch (TelegramApiException e) {
- log.info("Error setting webhook");
+// log.info("Error setting webhook");
+ System.out.println("Error setting webhook" + e);
}
}