Closed azimot closed 8 years ago
Same as in java, what about escaping it too with '\'? Another option is that you don't use Markdown parse mode.
with the '\' not worked but after i used to set SendMessage.enableHtml(true) worked !
I'm using '\' to escape character in the messages and works correctly. Maybe you are escaping too much or something. enabling html markdown just change the type of markdown.
yes it's worked ! i check in code and see i had a mistake by myself in end of SendMessage operation
What was exactly your error?
Currently, my problem is that I want to list all my users. With their First, Last and username. It seems that one user has special characters in this name that is interpreted as a markdown thing.
Since I get the same error message, I wonder If I do the same error as you did.
hmm in username phrase ! i dont think about it yet !! but i did catch that error when i want to send message to users because some message must be have some special characters and other dont need.
so in your case you could to create a Pattern Object and check username phrase with Regex if it's have markdown characters then enable markdown and if have html characters enable html i think in this way you could to resolve your problem
For me scaping _ with \ isn't working!
I also have problem like @hems, can't escape _ with .
@KilluaFein if i'm not mistaken i had to scape with \\
instead! like \\_
Yes, the problem is not solved yet
@Fotomultman do you escaped properly?
@Clevero I tried but no result :( I'm wondering, could you tell me please how to do it right?
//should fail
String text = "My amazing text _ is really awesome";
sendMessage.setText(text);
//escape the character
String text = "My amazing text \\_ is really awesome";
sendMessage.setText(text);
Some explanations in a Java tutorial at Oracle
@Clevero As you said before
//escape the character
String text = "My amazing text \\_ is really awesome";
sendMessage.setText(text);
works fine, but when I try to execute
sndMessage(message,message.getSticker().getFileId().replaceAll("_","\\_"))
Ther is the same error... :(
It it suitable to use replaceAll("_","\\_")
construction in this way?
Sorry if it is a silly question :)
P.S. BTW
System.out.println( message.getSticker().getFileId().replaceAll("_","\\_"));
shows result likeCAADAgADNgADGXMNCX5t7t_uKaEZAg
without \
before _
But Oracle manual says it would work ...
Have tested similar code to yours, cannot reproduce your issue:
String text = "My amazing text is _ awesome";
sndMessage(message,text.replaceAll("_","\\_"));
Whereas sndMessage()
is a method that creates a SendMessage object and fire its up with execute()
@Clevero
BTW
String mysticker;
String mysticker_txt;
mysticker_txt = message.getSticker().getFileId().replaceAll("_","\\\\_");
sndMessage(message,mysticker_txt);
It works with "\\\\_"
mask... dont know why
i catch exception when i want to sending underline '_' to bot
i find that happen when i had underline character in my message text it's seems underline is a special character in bot API like as '\' in java String that must be use '\' for that how can i to resolve ?