message Builder with encoded url
This commit is contained in:
parent
c971c05de3
commit
61527b9737
|
@ -98,13 +98,21 @@ public class MessageBuilder {
|
||||||
throw new IllegalArgumentException("attachment empty!");
|
throw new IllegalArgumentException("attachment empty!");
|
||||||
}
|
}
|
||||||
attachmenttype = type;
|
attachmenttype = type;
|
||||||
attachment = cont;
|
try {
|
||||||
|
attachment = URLEncoder.encode(cont, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder setCaption(String text) {
|
public MessageBuilder setCaption(String text) {
|
||||||
this.caption = text;
|
try {
|
||||||
|
this.caption = URLEncoder.encode(text, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +138,10 @@ public class MessageBuilder {
|
||||||
String cmd;
|
String cmd;
|
||||||
String text = "";
|
String text = "";
|
||||||
if(attachmenttype != Attachment.none) {
|
if(attachmenttype != Attachment.none) {
|
||||||
attachment = "&" + attachmenttype.name().toLowerCase() + "=" + this.attachment;
|
|
||||||
cmd = "send" + attachmenttype.name();
|
|
||||||
if(caption != null)
|
if(caption != null)
|
||||||
attachment += "&caption=" + caption;
|
attachment += "&caption=" + caption;
|
||||||
|
attachment = "&" + attachmenttype.name().toLowerCase() + "=" + this.attachment;
|
||||||
|
cmd = "send" + attachmenttype.name();
|
||||||
} else {
|
} else {
|
||||||
cmd = "sendMessage";
|
cmd = "sendMessage";
|
||||||
if(this.text != null) {
|
if(this.text != null) {
|
||||||
|
|
Loading…
Reference in New Issue