Skip to content

Commit

Permalink
🔇 silent changes: upgrade libs and add unify functions telegram wrap …
Browse files Browse the repository at this point in the history
…service #3 #2
  • Loading branch information
pnguyen215 committed Jul 7, 2024
1 parent 14d9527 commit 1d757d1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
Binary file modified libs/bot4j-v1.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.botwrap4j.service;

import org.bot4j.telegram.common.Telegram4j;
import org.bot4j.telegram.message.MessageBuilder;
import org.botwrap4j.model.request.TelegramClustersRequest;

public interface TelegramWrapService {
Expand All @@ -13,16 +14,24 @@ public interface TelegramWrapService {

void sendMessageSilent(String key, String message);

void sendMessageSilent(String key, MessageBuilder<?> message);

void sendMessageSilentAfterWaitSec(String key, long seconds, String message);

void sendMessageSilentAfterWaitSec(String key, long seconds, MessageBuilder<?> message);

void sendMessageSilent(String key, StringBuilder message);

void sendMessageSilent(String key, Object message);

void sendMessageSilent(String key, String clusterId, String message);

void sendMessageSilent(String key, String clusterId, MessageBuilder<?> message);

void sendMessageSilentAfterWaitSec(String key, String clusterId, long seconds, String message);

void sendMessageSilentAfterWaitSec(String key, String clusterId, long seconds, MessageBuilder<?> message);

void sendMessageSilent(String key, String clusterId, StringBuilder message);

void sendMessageSilent(String key, String clusterId, Object message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.botwrap4j.service.impl;

import org.bot4j.telegram.common.Telegram4j;
import org.bot4j.telegram.message.MessageBuilder;
import org.bot4j.telegram.model.builder.TelegramConnectionBuilder;
import org.botwrap4j.common.BotWrap4j;
import org.botwrap4j.model.request.TelegramClustersRequest;
Expand All @@ -12,6 +13,7 @@
import org.springframework.stereotype.Service;
import org.unify4j.common.Class4j;
import org.unify4j.common.Json4j;
import org.unify4j.common.String4j;
import org.unify4j.common.Time4j;

import java.util.Optional;
Expand Down Expand Up @@ -91,14 +93,26 @@ public void sendMessageSilent(String key, String message) {
telegram4j.requestId(BotWrap4j.getCurrentSessionId()).sendMessageSilent();
}

/**
* @param key - the key configured for telegram clusters
* @param message - the message builder, class {@link MessageBuilder}
*/
@Override
public void sendMessageSilent(String key, MessageBuilder<?> message) {
if (!botWrapService.isEnabled() || message == null) {
return;
}
this.sendMessageSilent(key, message.toString());
}

/**
* @param key - the key configured for telegram clusters,
* @param seconds - the second after waiting
* @param message - the message will be sent
*/
@Override
public void sendMessageSilentAfterWaitSec(String key, long seconds, String message) {
if (!botWrapService.isEnabled()) {
if (!botWrapService.isEnabled() || seconds < 0 || String4j.isEmpty(message)) {
return;
}
new Thread(() -> {
Expand All @@ -118,6 +132,19 @@ public void sendMessageSilentAfterWaitSec(String key, long seconds, String messa
}).start();
}

/**
* @param key - the key configured for telegram clusters,
* @param seconds - the second after waiting
* @param message - the message will be sent, class {@link MessageBuilder}
*/
@Override
public void sendMessageSilentAfterWaitSec(String key, long seconds, MessageBuilder<?> message) {
if (!botWrapService.isEnabled() || seconds < 0 || message == null) {
return;
}
this.sendMessageSilentAfterWaitSec(key, seconds, message.toString());
}

/**
* @param key - the key configured for telegram clusters,
* @param message - the message will be sent
Expand All @@ -143,7 +170,7 @@ public void sendMessageSilent(String key, Object message) {
*/
@Override
public void sendMessageSilent(String key, String clusterId, String message) {
if (!botWrapService.isEnabled()) {
if (!botWrapService.isEnabled() || String4j.isEmpty(clusterId)) {
return;
}
Telegram4j telegram4j = this.valueOf(key, clusterId, message);
Expand All @@ -153,6 +180,19 @@ public void sendMessageSilent(String key, String clusterId, String message) {
telegram4j.requestId(BotWrap4j.getCurrentSessionId()).sendMessageSilent();
}

/**
* @param key - the key configured for telegram clusters,
* @param message - the message will be sent
* @param clusterId - the cluster_id
*/
@Override
public void sendMessageSilent(String key, String clusterId, MessageBuilder<?> message) {
if (!botWrapService.isEnabled() || String4j.isEmpty(clusterId) || message == null) {
return;
}
this.sendMessageSilent(key, clusterId, message.toString());
}

/**
* @param key - the key configured for telegram clusters,
* @param message - the message will be sent
Expand All @@ -161,7 +201,7 @@ public void sendMessageSilent(String key, String clusterId, String message) {
*/
@Override
public void sendMessageSilentAfterWaitSec(String key, String clusterId, long seconds, String message) {
if (!botWrapService.isEnabled()) {
if (!botWrapService.isEnabled() || String4j.isEmpty(clusterId) || seconds < 0) {
return;
}
new Thread(() -> {
Expand All @@ -181,6 +221,20 @@ public void sendMessageSilentAfterWaitSec(String key, String clusterId, long sec
}).start();
}

/**
* @param key - the key configured for telegram clusters,
* @param message - the message will be sent
* @param clusterId - the cluster_id
* @param seconds - the second after waiting
*/
@Override
public void sendMessageSilentAfterWaitSec(String key, String clusterId, long seconds, MessageBuilder<?> message) {
if (!botWrapService.isEnabled() || String4j.isEmpty(clusterId) || seconds < 0 || message == null) {
return;
}
this.sendMessageSilentAfterWaitSec(key, clusterId, seconds, message.toString());
}

/**
* @param key - the key configured for telegram clusters,
* @param message - the message will be sent
Expand Down

0 comments on commit 1d757d1

Please sign in to comment.