示例#1
0
    def create_callback_query(self, json_obj):
        query_id = self._get_simple_field(json_obj, 'id')
        from_user = self.get_from(json_obj)
        message = self.get_message(json_obj)
        chat_instance = self._get_simple_field(json_obj, 'chat_instance')
        inline_message_id = self._get_simple_field(json_obj, 'inline_message_id')
        data = self._get_simple_field(json_obj, 'data')
        game_short_name = self._get_simple_field(json_obj, 'game_short_name')

        callback_query = CallbackQuery(
            id=query_id, from_user=from_user, chat_instance=chat_instance
        )

        if message:
            callback_query.message = message

        if inline_message_id:
            callback_query.inline_message_id = inline_message_id

        if data:
            callback_query.data = data

        if game_short_name:
            callback_query.game_short_name = game_short_name

        return callback_query
def callback_query(bot, request):
    cbq = CallbackQuery(TestCallbackQuery.id_,
                        TestCallbackQuery.from_user,
                        TestCallbackQuery.chat_instance,
                        data=TestCallbackQuery.data,
                        game_short_name=TestCallbackQuery.game_short_name,
                        bot=bot)
    if request.param == 'message':
        cbq.message = TestCallbackQuery.message
    else:
        cbq.inline_message_id = TestCallbackQuery.inline_message_id
    return cbq
def callback_query(bot, request):
    cbq = CallbackQuery(TestCallbackQuery.id,
                        TestCallbackQuery.from_user,
                        TestCallbackQuery.chat_instance,
                        data=TestCallbackQuery.data,
                        game_short_name=TestCallbackQuery.game_short_name,
                        bot=bot)
    if request.param == 'message':
        cbq.message = TestCallbackQuery.message
    else:
        cbq.inline_message_id = TestCallbackQuery.inline_message_id
    return cbq