Merge pull request #539 from aNNiMON/switchpmparameter-fix

Allow hyphen character in switchPmParameter
This commit is contained in:
Ruben Bermudez 2018-12-11 00:49:43 +00:00 committed by GitHub
commit c71c2a3c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -136,8 +136,8 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
if (switchPmParameter.length() > 64) {
throw new TelegramApiValidationException("SwitchPmParameter can't be longer than 64 chars", this);
}
if (!Pattern.matches("[A-Za-z0-9_]+", switchPmParameter.trim() )) {
throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9 and _ characters", this);
if (!Pattern.matches("[A-Za-z0-9_\\-]+", switchPmParameter.trim() )) {
throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", this);
}
}
for (InlineQueryResult result : results) {

View File

@ -113,7 +113,7 @@ public class TestAnswerInlineQuery {
try {
answerInlineQuery.validate();
} catch (TelegramApiValidationException e) {
Assert.assertEquals("SwitchPmParameter only allows A-Z, a-z, 0-9 and _ characters", e.getMessage());
Assert.assertEquals("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", e.getMessage());
}
}
}