mirror of
https://github.com/valitydev/alert-tg-bot.git
synced 2024-11-06 01:55:23 +00:00
Cache inline results and use fixed length ids (#25)
This commit is contained in:
parent
3735efc270
commit
645dee5457
@ -17,4 +17,5 @@ public class AlertBotProperties {
|
||||
private String name;
|
||||
@NotNull
|
||||
private String chatId;
|
||||
private Integer cacheOptionsSec = 0;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import dev.vality.alerting.mayday.UserAlert;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.thrift.TException;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@ -98,7 +99,7 @@ public class InlineHandler implements CommonHandler<AnswerInlineQuery> {
|
||||
String description,
|
||||
InputTextMessageContent inputTextMessageContent) {
|
||||
InlineQueryResultArticle inlineQueryResultArticle = new InlineQueryResultArticle();
|
||||
inlineQueryResultArticle.setId(id);
|
||||
inlineQueryResultArticle.setId(DigestUtils.sha256Hex(id));
|
||||
inlineQueryResultArticle.setTitle(id);
|
||||
inlineQueryResultArticle.setDescription(description);
|
||||
inlineQueryResultArticle.setInputMessageContent(inputTextMessageContent);
|
||||
|
@ -63,7 +63,7 @@ public class AlertBot extends TelegramLongPollingBot {
|
||||
execute(sendMessage);
|
||||
} else if (answer instanceof AnswerInlineQuery answerInlineQuery) {
|
||||
answerInlineQuery.setIsPersonal(true);
|
||||
answerInlineQuery.setCacheTime(0);
|
||||
answerInlineQuery.setCacheTime(alertBotProperties.getCacheOptionsSec());
|
||||
execute(answerInlineQuery);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user