message Builder with encoded url

This commit is contained in:
MrBesen 2019-02-11 16:38:05 +01:00
parent c971c05de3
commit 61527b9737
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 12 additions and 4 deletions

View File

@ -98,13 +98,21 @@ public class MessageBuilder {
throw new IllegalArgumentException("attachment empty!");
}
attachmenttype = type;
attachment = cont;
try {
attachment = URLEncoder.encode(cont, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return this;
}
public MessageBuilder setCaption(String text) {
this.caption = text;
try {
this.caption = URLEncoder.encode(text, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return this;
}
@ -130,10 +138,10 @@ public class MessageBuilder {
String cmd;
String text = "";
if(attachmenttype != Attachment.none) {
attachment = "&" + attachmenttype.name().toLowerCase() + "=" + this.attachment;
cmd = "send" + attachmenttype.name();
if(caption != null)
attachment += "&caption=" + caption;
attachment = "&" + attachmenttype.name().toLowerCase() + "=" + this.attachment;
cmd = "send" + attachmenttype.name();
} else {
cmd = "sendMessage";
if(this.text != null) {