- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有这个按钮,我想在单击它后将其删除。但点击它不会生成更新?
if (Objects.equals(text.toUpperCase(), "TEST")){
String out = link;
try {
SendMessage sendMessage=new SendMessage().setChatId(update.getMessage().getChatId()).setText("JOIN THE CHANNEL!");
InlineKeyboardMarkup markupInline = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> rowsInline = new ArrayList<>();
List<InlineKeyboardButton> rowInline = new ArrayList<>();
rowInline.add(new InlineKeyboardButton().setText("JOIN").setCallbackData("JOIN_PREMIUM").setUrl(link));
rowsInline.add(rowInline);
markupInline.setKeyboard(rowsInline);
sendMessage.setReplyMarkup(markupInline);
sendMessage(sendMessage);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
要在按下时决定一个 Action ,我有:
else if (update.hasInlineQuery()||update.hasCallbackQuery()||update.hasChosenInlineQuery()||update.hasPreCheckoutQuery()||update.hasShippingQuery()){
String call_data = update.getCallbackQuery().getData();
System.out.println("CALL DATA: "+call_data);
int message_id = update.getCallbackQuery().getMessage().getMessageId();
long chat_id = update.getCallbackQuery().getMessage().getChatId();
if (Objects.equals(call_data, "JOIN_PREMIUM")){
EditMessageText editMessageText = new EditMessageText().setMessageId(message_id).setChatId(chat_id);
editMessageText.setText("Welcome to the club!");
try {
editMessageText(editMessageText);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
但这没有用,因为它没有提供更新,但应该!有没有人有解决办法?
最佳答案
InlineKeyboardButton 中的
url 和 callback_data 是可选字段。
You must use exactly one of the optional fields.
documentation for InlineKeyboardButton
所以,问题就在这里:
rowInline.add(new InlineKeyboardButton()
.setText("JOIN")
.setCallbackData("JOIN_PREMIUM")
.setUrl(link));
您应该删除其中一个
.setCallbackData("JOIN_PREMIUM")
或
.setUrl(link)
我还有一点不重要的评论。这一行有很多冗余
else if (update.hasInlineQuery()||update.hasCallbackQuery()||update.hasChosenInlineQuery()||update.hasPreCheckoutQuery()||update.hasShippingQuery())
您可以将其缩短为
else if (update.hasCallbackQuery())
关于java - 电报机器人 java : inline url button does not create an update and thus no callback data to respond on,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49919212/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!