disable web preview in feedbackinfo; added allow_sending_without_reply in messagebuilder

This commit is contained in:
mrbesen 2021-01-12 13:01:49 +01:00
parent 7d1e478260
commit 6ca91303b3
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 20 additions and 3 deletions

View File

@ -14,6 +14,7 @@ public class MessageBuilder {
private Formatting format = Formatting.None;
private boolean silent = false;
private boolean no_web_view = false;
private boolean allow_sending_without_reply = false;
private long reciver_id = 0;
private int reply_to_message_id = 0;
private TReplyMarkup markup = null;
@ -149,6 +150,16 @@ public class MessageBuilder {
return this;
}
/**
* should fail when a message, thats replyed to is not existent default is true
* @param b
* @return this
*/
public MessageBuilder setFailwithoutReply(boolean b) {
allow_sending_without_reply = !b;
return this;
}
public SendableMessage build() {
if(reciver_id == 0) {
throw new MissingException("Reciver");
@ -191,10 +202,13 @@ public class MessageBuilder {
}
}
if(no_web_view) {
optionals += "&disable_web_page_preview=" + no_web_view;
optionals += "&disable_web_page_preview=true";
}
if(silent) {
optionals += "&disable_notification=" + silent;
optionals += "&disable_notification=true";
}
if(allow_sending_without_reply) {
optionals += "&allow_sending_without_reply=true";
}
String q = "chat_id=" + reciver_id + text + optionals + attachment;

View File

@ -103,9 +103,12 @@ public class FeedbackCommand implements JSONCommandHandler {
protected MessageBuilder createInfo(TUser u, int msgid, boolean firstmsg) {
String info = "Feedbackinfo:\n" + "userid: " + u.getID() + "\nusername: " + u.getName() + "\nfullname: " + u.getFirstName() + ' ' + u.getLastName();
MessageBuilder mb = new MessageBuilder().setAsync();
if(firstmsg && feedbackCallback != null) {
try {
info += '\n' + feedbackCallback.apply(u);
mb.setNoWebView(true);
} catch (Throwable t) {
info += "\nError getting information: " + t.getMessage();
t.printStackTrace();
@ -115,7 +118,7 @@ public class FeedbackCommand implements JSONCommandHandler {
TInlineKeyboardMarkup markup = new TInlineKeyboardMarkup(1);
markup.addUrlButton("chat with user", "https://t.me/" + u.getName(), 1);
markup.addCallbackButton("↩ reply", buildRplyCallback(u.getID(), msgid), 1);
return new MessageBuilder().setAsync().setText(info).setFormatting(MessageBuilder.Formatting.HTML).setMarkup(markup);
return mb.setText(info).setFormatting(MessageBuilder.Formatting.HTML).setMarkup(markup);
}
public boolean onCallback(UserCallbackEvent e) {