Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class TelegramNotifier extends AbstractContentNotifier {
*/
@Nullable private String chatId;

/**
* Unique identifier for the target topic of the target super group
*/
private Integer messageThreadId;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mark it with @Nullable for consistency.


/**
* The token identifying und authorizing your Telegram bot (e.g.
* `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11`)
Expand Down Expand Up @@ -75,14 +80,17 @@ protected Mono<Void> doNotify(InstanceEvent event, Instance instance) {
.fromRunnable(() -> restTemplate.getForObject(buildUrl(), Void.class, createMessage(event, instance)));
}

protected String buildUrl() {
return String.format("%s/bot%s/sendmessage?chat_id={chat_id}&text={text}&parse_mode={parse_mode}"
+ "&disable_notification={disable_notification}", this.apiUrl, this.authToken);
}
protected String buildUrl() {
return String.format(
"%s/bot%s/sendmessage?chat_id={chat_id}&message_thread_id={message_thread_id}&text={text}&parse_mode={parse_mode}&disable_notification={disable_notification}",
this.apiUrl, this.authToken
);
}

private Map<String, Object> createMessage(InstanceEvent event, Instance instance) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("chat_id", this.chatId);
parameters.put("message_thread_id", this.messageThreadId);
parameters.put("parse_mode", this.parseMode);
parameters.put("disable_notification", this.disableNotify);
parameters.put("text", createContent(event, instance));
Expand Down Expand Up @@ -114,6 +122,14 @@ public void setChatId(@Nullable String chatId) {
this.chatId = chatId;
}

public Integer getMessageThreadId() {
return messageThreadId;
}

public void setMessageThreadId(Integer messageThreadId) {
this.messageThreadId = messageThreadId;
}

@Nullable public String getAuthToken() {
return authToken;
}
Expand Down
Loading