answerCallbackQuery method

Future<bool> answerCallbackQuery({
  1. String? text,
  2. bool showAlert = false,
  3. String? url,
  4. int cacheTime = 0,
})

Answers the callback query in the current update.

This method can only be called when the update contains a callback query.

Example:

await ctx.answerCallbackQuery(text: 'Button clicked!');
await ctx.answerCallbackQuery(text: 'Error occurred!', showAlert: true);

Implementation

Future<bool> answerCallbackQuery({
  String? text,
  bool showAlert = false,
  String? url,
  int cacheTime = 0,
}) async {
  final query = callbackQuery;
  _verifyInfo(
    [query],
    APIMethod.answerCallbackQuery,
    description: "No callback query found in the current update.",
  );

  return api.answerCallbackQuery(
    query!.id,
    text: text,
    showAlert: showAlert,
    url: url,
    cacheTime: cacheTime,
  );
}