Coder Social home page Coder Social logo

Comments (4)

bwilkerson avatar bwilkerson commented on August 17, 2024

Can you provide us with a (preferably minimal) reproduction case?

from sdk.

busslina avatar busslina commented on August 17, 2024

Can you provide us with a (preferably minimal) reproduction case?

Sure:

Top level extension:

extension TCallbackQueryBaseExtension on TCallbackQuery {
  String get _urlAnswerInlineQuery => '/answerInlineQuery';

  /// [API: answercallbackquery](https://core.telegram.org/bots/api#answercallbackquery)
  ///
  /// Send answers to callback queries sent from [inline keyboards](https://core.telegram.org/bots/features#inline-keyboards).
  ///
  /// [text] Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.
  ///
  /// [showAlert] If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
  ///
  /// [url] URL that will be opened by the user's client.
  ///
  /// [cacheTime]  	The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
  Future<Ret<TMessage, TelegramError>> answerCallbackQueryBase({
    required Lock lock,
    required Dio httpClient,
    String? text,
    bool? showAlert,
    String? url,
    int? cacheTime,
  }) =>

      // Lock mode
      lock.synchronized(() async {
        final res = await handleResponse(
          httpClient.post(
            _urlAnswerInlineQuery,
            data: {
              'callback_query_id': id,
              if (text != null) 'text': text,
              if (showAlert != null) 'show_alert': showAlert,
              if (cacheTime != null) 'cache_time': cacheTime,
            },
          ),
        );

        // final data = res.response.data;
        // final success = res.statusCode == 200 && data['ok'] == true;

        debug(
            'answerCallbackQueryBase() -- ${res.statusCode} -- ${res.response.data}');

        throw ('Not implemented');

        // return Ret(
        //   success: success,
        //   value: success ? TMessage.fromJson(data['result']) : null,
        //   errMessage: 'Unknown error -- ${res.response.data}',
        //   errValue: success ? null : TelegramError.uknownError,
        // );
      });
}

Other extension:

extension TCallbackQueryExtension on TCallbackQuery {
  TelegramModule get _module => cc.read(telegramModuleCapsule);

  TelegramBotV2 get _bot => _module.bot;

  Future<Ret<TMessage, TelegramError>> answerCallbackQueryN({
    String? text,
    bool? showAlert,
    String? url,
    int? cacheTime,
  }) {
    final bot = _bot;

    return bot.lock.synchronized(() async {
      final res = await handleResponse(
        bot.httpClient.post(
          _urlAnswerInlineQuery,
          data: {
            'callback_query_id': id,
            if (text != null) 'text': text,
            if (showAlert != null) 'show_alert': showAlert,
            if (cacheTime != null) 'cache_time': cacheTime,
          },
        ),
      );

      // final data = res.response.data;
      // final success = res.statusCode == 200 && data['ok'] == true;

      debug(
          'answerCallbackQueryN() -- ${res.statusCode} -- ${res.response.data}');

      throw ('Not implemented');
    });
  }
}

You can see that the second extension uses a private field (_urlAnswerInlineQuery ) of the first extension. This fails at compile time but not at analysis time. (This is what I show in the demo video)

from sdk.

bwilkerson avatar bwilkerson commented on August 17, 2024

Are the two extensions defined in different libraries? (I'm guessing the answer is yes, but want to be sure.)

from sdk.

busslina avatar busslina commented on August 17, 2024

Are the two extensions defined in different libraries? (I'm guessing the answer is yes, but want to be sure.)

Yes. I'm using a VSCode workspace that includes both libraries

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.